Centos7使用yum安装Mysql5.7.19的详细步骤(可用)

Centos7的yum源中默认是没有mysql,由于如今已经用mariaDB代替mysql了。mysql

首先咱们下载mysql的repo源,咱们能够去mysql官网找最新的repo源地址linux

地址:sql

https://dev.mysql.com/downloads/repo/yum/
bash

开始在linux下下载repo源ide

?
1
2
3
4
5
6
7
8
// 下载mysql rpm包
 
// 安装mysql rpm包
# rpm -ivh mysql57-community-release-el7-11.noarch.rpm
 
// 安装mysql
# yum install mysql-community-server

安装成功后须要重启mysql服务。ui

?
1
# service mysqld restart

刚开始安装的Mysql5.7是会随机生成一个root密码的,咱们要先找到这个随机密码,而后改新密码。咱们能够经过grep命令查找随机root密码。spa

?
1
2
[root@ local bin]# grep "password" /var/log/mysqld.log
2017-09-24T08:03:30.664086Z 1 [Note] A temporary password is generated for root@localhost: 8A3xwbk8_P1A

使用随机密码登陆mysql.net

?
1
2
[root@ local bin]# mysql -uroot -p
Enter password :

进入后重置root密码rest

?
1
2
mysql> SET password = PASSWORD ( "mysql123" );
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

若是有上面的报错,说明密码设置的过于简单。密码设置规则是要有数字大小写字母和字符串。
code

最后授予外网登陆权限,username为用户名,password是登陆密码

?
1
mysql> grant all privileges on *.* to username@ '%' identified by 'password' ;