lxq.link
postscategoriestoolsabout

MySQL remote connection

开启远程访问权限

登录mysql

mysql -u root -p

执行sql语句

use mysql;
-- % => 所有ip都可以远程访问
update user set host = '%' where user = 'root';  
-- 查看修改
select host, user from user;

FLUSH PRIVILEGES;

Check status:

netstat -tulpen

Modify mysql configuration:

vi /etc/mysql/mysql.conf.d/mysqld.cnf

# Edit:
bind-address = 0.0.0.0

Restart mysql

sudo service mysql restart

远程访问mysql

mysql -h <host> -P 3306 -u root -p
2018-12-19