Centos 7 下安装mysql
// 卸载原有maridb-lib库
[root@localhost ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.41-2.el7_0.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件
# yum -y install wget
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum -y install mysql-community-server
成功安装之后重启mysql服务
# service mysqld restart
初次安装mysql是root账户是没有密码的
设置密码的方法
# mysql -uroot
// mysql> set password for ‘root’@‘localhost’ = password('mypasswd');//若不需要密码可以不执行此步骤
mysql> use mysql;
mysql> update user set password=password('123') where user='root'';
mysql> flush privileges;
赋予权限增加用户
mysql> grant all privileges on *.* to 'root'@'%' identified by '' with grant option;
mysql> grant all privileges on *.* to 'localhost'@'%' identified by '' with grant option;
mysql> grant all privileges on *.* to 'Acswxf'@'localhost' identified by 'Acswxf' with grant option;
mysql> FLUSH PRIVILEGES;
mysql> exit;
这里数据库安装就完成了
下面将已有数据库文件(/root/test.sql)导入数据库MYDB
# mysql -uroot //进入数据库
mysql> drop database MYDB;
mysql> create database MYDB;
mysql> use MYDB;
mysql> set names utf8;
mysql> source /root/test.sql;
最后,记得将test.sql删除。//忽略