Linux服务器MySQL开启远程连接
登陆服务器,登陆mysql
mysql -u root -p
创建远程连接账号,并且新设置用户或更改密码后需用flush privileges刷新
GRANT ALL PRIVILEGES ON . TO ‘用户名’@’%’ IDENTIFIED BY ‘密码’ WITH GRANT OPTION;
flush privileges;
Linux系统MySQL开启远程连接
SELECT DISTINCT CONCAT(‘User: ”’,user,”’@”’,host,”’;’) AS query FROM mysql.user;
Linux系统MySQL开启远程连接
- 使用exit命令退出MySQL
- 然后打开vim /etc/mysql/my.cnf
- 将bind-address = 127.0.0.1 设置成 bind-address = 0.0.0.0(设备地址)
重新启动mysql(命令如下):
/etc/init.d/mysql stop
/etc/init.d/mysql start
Linux系统MySQL开启远程连接
- 查看端口号
show global variables like 'port';