允许ubuntu下mysql远程连接

2016-09-28  本文已影响42人  Junting

第一步:

twitch@ubuntu1:~$ sudo vim /etc/mysql/my.cnf 

vim /etc/mysql/my.cnf 里找到 bind-address = 127.0.0.1
注释掉这行,如:#bind-address = 127.0.0.1

或者改为: bind-address = 0.0.0.0

允许任意IP访问;
或者自己指定一个IP地址。

重启 MySQL: twitch@ubuntu1:~$ sudo /etc/init.d/mysql restart

第二步:授权用户能进行远程连接

twitch@ubuntu1:~$ mysql -uroot -p
Enter password: 

mysql> grant all privileges on *.* to root@"%" identified by "123456" with grant option; 
Query OK, 0 rows affected (0.00 sec)

mysql>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

上一篇下一篇

猜你喜欢

热点阅读