有关Mysql远程连接报错的坑
-
服务未启动
-
服务已经启动, 本机可登入,其他机器均不可
在其他机器上可以ssh/ping通,但是telnet ip port失败
有可能是配置文件的原因
/etc/mysql/mysql.conf.d/mysqld.cnf
# Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 mysqlx-bind-address = 127.0.0.1
将这两行(3-4)注释掉
-
ERROR 1698 (28000): Access denied for user 'root'@'XXX'
这是表内定义的权限问题
先登入mysql(8.0以上版本)
create user root@'%' identified by '密码'; grant all privileges on *.* to root@'%' with grant option;
其中设置密码可能不符合其中规范会报错,所以可以先修改规范,然后再运行上面两条语句
mysql> show variables like 'validate_password%'; +--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password.check_user_name | ON | | validate_password.dictionary_file | | | validate_password.length | 8 | | validate_password.mixed_case_count | 1 | | validate_password.number_count | 1 | | validate_password.policy | MEDIUM | | validate_password.special_char_count | 1 | +--------------------------------------+--------+ set global validate_password.policy=0; mysql> show variables like 'validate_password%'; +--------------------------------------+-------+ | Variable_name | Value | +--------------------------------------+-------+ | validate_password.check_user_name | ON | | validate_password.dictionary_file | | | validate_password.length | 8 | | validate_password.mixed_case_count | 1 | | validate_password.number_count | 1 | | validate_password.policy | LOW | | validate_password.special_char_count | 1 | +--------------------------------------+-------+ set global validate_password.length = 6;
-
重启mysql服务后,即可再次登入