liunx contos7 安装mysql 8.0 详细步骤

安装mysql 8.0 步骤
1. contos7默认安装了mariadb数据库 需要移除
yum remove mariadb-libs.x86_64

2.获取yum repository下载资源
wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm

3 添加到本地
yum localinstall  mysql80-community-release-el7-2.noarch.rpm

4. 查看有没有添加成功
yum search mysql

5.安装
yum install mysql-community-server

6.启动测试
service mysqld start     
service mysqld status

7.查找默认密码 LSH?/pEux9UX
cat /var/log/mysqld.log | grep password

8.登录
mysql -u root -p 然后输入密码

9.修改密码
ALTER USER "root"@"localhost" IDENTIFIED  BY "1234";(mysql默认密码等级比较高需要大小字母加特殊符号数字 
想要简单密码设置1.set global validate_password.policy=0;2.set global validate_password.length=1;)

10.退出 重新登录
exit  

mysql -u root -p   

11.授权远程访问(确定关闭防火墙)

    选择数据库  use mysql    
        show tables;可以看到很多表
      修改连接规则:host表示允许哪个ip来连接,user表示哪个数据库。例如 mysql –uroot –p 连的就是叫root数据库
      查看规则   select host,user from user \G;      
      修改规则 update user set host= '%' where user = 'root'; 
12.修改加密规则
update user set plugin='mysql_native_password' where user ='root';

13.刷新权限
flush privileges;

14.重新新修改密码
ALTER USER "root"@"%" IDENTIFIED WITH mysql_native_password BY "chen199419@";

可能会遇到
 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
错误
如遇上以上问题请使用update语句先清空authentication_string字段,然后再修改密码即可
update user set authentication_string='' where user='root'; (='' 不行的话就用 =null)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码'

结束: 我也是折腾很长时间 希望能帮助你们

你可能感兴趣的:(liunx contos7 安装mysql 8.0 详细步骤)