Mysql数据库服务端配置远程访问
- 连接数据库
# 登录数据库
mysql -u root -p
- 修改数据库连接密码root用户名,'password'改为你的密码
use mysql;
set password for root@localhost = password('password');
- 执行以下命令开启远程访问。
# '%' 表示任意地址可访问
grant all privileges on *.* to 'root'@'%' identified by 'password';
# 刷新配置
flush privileges;
- 重点 : 修改配置文件, 把
bind-address = 127.0.0.1
这一行注释掉
# 打开配置文件
# MariaDB版本号:10.11.8, 路径如下:
vim /etc/mysql/mariadb.conf.d/50-server.cnf
# 注释此行:
# bind-address = 127.0.0.1
- 重启mysql服务或者重启
systemctl restart mysql