linux下mysql远程链接报错

1.登录mysql

mysql -u root(账户名) -p

 

2.查看端口号

 使用命令show global variables like 'port';查看端口号

 

3.找到并执行vi  /etc/mysql/mysql.conf.d/mysqld.cnf

 在下面行的开头加上#,注释掉该行,然后保存退出vim(路径可能有不同)

 

bind-address = 127.0.0.1

 

4.进入mysql授权root用户访问权限并刷新

grant all privileges on *.* to root@"%" identified by "password" with grant option;

flush privileges;

exit;

重启mysqlservice mysql restart

注:rootmysql登录账户名,passwordroot用户对应的密码,其中root用户可以更改


进行远程登录

mysql -u root -p -h 10.178.0.41

root@ubuntu:/work/install# mysql -u root -p -h 10.178.0.41
Enter password: 


你可能感兴趣的:(linux下mysql远程链接报错)