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

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

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

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

 

地址:

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

开始在linux下下载repo源


//下载mysql rpm包
# wget 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服务。

?
# service mysqld restart
刚开始安装的Mysql5.7是会随机生成一个root密码的,我们要先找到这个随机密码,然后改新密码。我们可以通过grep命令查找随机root密码。



[[email protected] bin]# grep "password" /var/log/mysqld.log
2017-09-24T08:03:30.664086Z 1 [Note] A temporary password is generated for [email protected]: 8A3xwbk8_P1A
使用随机密码登录mysql


[[email protected] bin]# mysql -uroot -p
Enter password:
进入后重置root密码


mysql> SET password=PASSWORD("mysql123");
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
如果有上面的报错,说明密码设置的过于简单。密码设置规则是要有数字大小写字母和字符串。

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


mysql>grant all privileges on *.* to [email protected]'%' identified by 'password';

 

查询用户权限

SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;

添加用户:grant all privileges on *.* to [email protected]'192.168.0.%' identified by '密码password';

FLUSH PRIVILEGES;刷新生效

 


--------------------- 
作者:rainyday66 
来源:CSDN 
原文:https://blog.csdn.net/qq_34173549/article/details/79692591 
版权声明:本文为博主原创文章,转载请附上博文链接!