快速学习Linux-MySQL5.7的安装

1、先把postfix 和mariadb-libs卸载掉,不然的会有依赖包冲突:

[root@wolfcode]#  rpm -e postfix mariadb-libs

2、安装mysql的依赖net-tools和 perl

yum -y install net-tools perl

3、安装mysql-common包:

[root@wolfcode]#  	

4、安装mysql-libs包:

[root@wolfcode]# rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm

5、安装mysql-client包;

[root@wolfcode]# rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm

6、安装mysql-server包

[root@wolfcode]# rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm

5、设置开机启动:

[root@wolfcode]# systemctl enable mysqld

6、启动MySql服务

[root@wolfcode]# systemctl start mysqld

7、由于MySQL5.7安装好后会给root用户分配一个临时密码,所以我们先查看临时密码

[root@wolfcode]#  grep 'temporary password' /var/log/mysqld.log
2018-06-01T19:40:08.341478Z 1 [Note] A temporary password is generated for root@localhost: Ct<pX.k7S(=w

冒号后面的就是root用户的临时密码:Ct
8、使用临时密码登录

[root@wolfcode]# mysql -u root -p

输入密码:Ct

9、设置root的密码

mysql>ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘WolfCode_2017’;
mysql> exit

注意:mysql5.7增加了安全级别,密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。

10、用新密码登陆

[root@wolfcode]# mysql -u root -p

输入密码:WolfCode_2017

11、开放远程登录权限

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'WolfCode_2017' 	WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;

12、开放mysql的3306端口

[root@wolfcode]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
[root@wolfcode]# firewall-cmd --reload

你可能感兴趣的:(快速学习)