1.Centos7 默认数据库是mariabd,安装mysql首先要把它卸载
yum remove mariadb-libs.x86_64
2.然后进入到yum源文件中
cd /etc/yum.repo.d
3.添加mysql-community.repo
vim mysql-community.repo
把这段代码添加进去
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
4.保存退出
5.yum install mysql-community-server
7.用root用户打开mysql,默认没有密码直接回车
mysql -uroot -p
select user,host,password from mysql.user where user='root';
+------+-----------------------+----------+
| user | host | password |
+------+-----------------------+----------+
| root | localhost | |
| root | localhost.localdomain | |
| root | 127.0.0.1 | |
| root | ::1 | |
+------+-----------------------+----------+
rows in set (0.00 sec)
update mysql.user set password=password('123456') where user='root';
update mysql.user set host='%' where user='root' and host='127.0.0.1';
flush privileges;