阿里云服务器安装mysql8遇到的问题
1.提供一个离线mysql下载路径:http://mirrors.163.com/mysql/Downloads/MySQL-8.0/
2.在线mysql8安装:
2.1 下载mysql:
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
yum -y localinstall mysql80-community-release-el7-1.noarch.rpm
2.2 启动mysql:
systemctl start mysqld
systemctl daemon-reload
2.3 首先获取默认密码 :
grep "A temporary password is generated for root@localhost" /var/log/mysqld.log
2.4 登陆:
mysql -uroot -p
2.5 修改密码的命令:
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码'; //mysql8新密码需要大小写字母数字符号
问题:至此mysql8已经安装完成,但是不能够远程访问,使用telnet 可以连接 22端口,但是无法访问3306端口;
解决:1.检查防火墙,
2.设置root访问权限,mysql8要设置mysql_native_password
CREATE USER ‘root’@’%’ IDENTIFIED BY '密码';
GRANT ALL ON *.* TO ‘root’@’%’;
ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ’密码’;
刷新权限 flush privileges;
注意:连接mysql 时,地址可能和连接xshell ip不一样 ifconfig查看地址