centos7安装mysql8

安装mysql前要先删除本机安装的mariadb

检查已经安装的mariadb列表

[root@iZ1i4qd6oynml0Z ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64

然后执行删除

[root@iZ1i4qd6oynml0Z ~]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

下面开始安装mysql

更新yum源

yum update

下载mysql yum包

wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

安装软件源

rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

安装mysql,后面的一直输入y就好了

yum install mysql-community-server

启动mysql

service mysqld start

查看MySQL运行状态

service mysqld status

查看mysql默认密码,最后那一串就是默认的密码

grep 'temporary password' /var/log/mysqld.log

登录mysql,输入上面步骤得到的默认密码

[root@iZ1i4qd6oynml0Z ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.19

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

修改密码

set global validate_password.policy=0;
set global validate_password.length=1;
ALTER USER "root"@"localhost" IDENTIFIED  BY "1234";
flush privileges;

授权远程访问

选择数据库

use mysql

查看user表内容

select host,user from user;

修改内容

update user set host= '%' where user = 'root'; 
flush privileges;

关于SQLyog 报错2058

登录mysql后,再次输入以下命令,就可以访问了

set global validate_password.policy=0;
set global validate_password.length=1;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '1234';
flush privileges;
posted @ 2020-04-12 17:14  麻辣猪仔  阅读(230)  评论(0编辑  收藏  举报