Centos7的yum源中默认是没有mysql,因为现在已经用mariaDB代替mysql了。

首先我们下载mysql的repo源,我们可以去mysql官网找最新的repo源地址


<http://files.jb51.net/file_images/article/201709/2017925142222928.jpg?2017825142248>

地址:

https://dev.mysql.com/downloads/repo/yum/
<https://dev.mysql.com/downloads/repo/yum/>


开始在linux下下载repo源
? <http://www.jb51.net/article/124518.htm#>
12345678//下载mysql rpm包# wget
http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
<http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm> //
安装mysql rpm包# rpm -ivh mysql57-community-release-el7-11.noarch.rpm //安装mysql#
yum install mysql-community-server
安装成功后需要重启mysql服务。
? <http://www.jb51.net/article/124518.htm#>
1# service mysqld restart
刚开始安装的Mysql5.7是会随机生成一个root密码的,我们要先找到这个随机密码,然后改新密码。我们可以通过grep命令查找随机root密码。
? <http://www.jb51.net/article/124518.htm#>
12[[email protected] bin]# grep "password" /var/log/mysqld.log
2017-09-24T08:03:30.664086Z 1 [Note] Atemporary password is generated for
[email protected]: 8A3xwbk8_P1A
使用随机密码登录mysql
? <http://www.jb51.net/article/124518.htm#>
12[[email protected] bin]# mysql -uroot -pEnter password:
进入后重置root密码
? <http://www.jb51.net/article/124518.htm#>
12mysql> SET password=PASSWORD("mysql123");ERROR 1819 (HY000): Your password
doesnot satisfy the current policy requirements
如果有上面的报错,说明密码设置的过于简单。密码设置规则是要有数字大小写字母和字符串。


最后授予外网登录权限,username为用户名,password是登录密码
? <http://www.jb51.net/article/124518.htm#>
1mysql>grant all privileges on *.* to [email protected]'%' identified by 'password';