mysql 8 的远程连接问题

问题:最近开始用mysql8,结果发现在sql语法比之前的版本严格了许多。。此处先解决授权sql报错问题,报错如下

mysql> grant all on dev1_test1.* to dev1@'%' identified by '12345678';

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by '12345678'' at line 1

解决:mysql8 要求先建用户,后授权

# 新增用户、授权
mysql> create user admin@'%' identified by 'kFONVz22'; 
 
mysql> GRANT all on *.* TO admin@'%';
 
 
mysql> flush privileges;
 
# 取消授权
 msyql> revoke all ON *.*  FROM admin@'%';

转载自:https://blog.csdn.net/qq_40168110/article/details/96859947

然后打开mysql默认的3306端口

firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --reload

然后允许使用旧的密码验证方式:

ALTER USER 'admin'@'%' IDENTIFIED WITH mysql_native_password BY 'password';

最后 sqlyog就可以远程登陆了。

如果先安装了一个版本的,再安装新版本,需要先把旧版本的数据删除,否则启动不起来,重点是删除 /var/lib/mysql下的所有文件

密码强度修改:0 是low, 1是medium,2是high

select @@validate_password_policy
set global validate_password_policy=0;
update mysql.user set authentication_string=password('new password') where user='root' ;

允许root 远程登录:
grant all privileges on . to 'root'@'%' identified by 'password' with grant option;
select host,user from user where user='root'
flush privileges;

你可能感兴趣的:(mysql 8 的远程连接问题)