MySQL远程连接数据库
一、修改/etc/mysql/my.conf
找到bind-address = 127.0.0.1这一行
改为bind-address = 0.0.0.0 记得重启服务
1.建个数据库用于远程访问:
CREATE DATABASE db_firm DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
2.配置一个用户用于远程登录:
CREATE USER ‘user1'@'%' IDENTIFIED BY '123';
3.授予用户权限:
GRANT ALL PRIVILEGES ON db_firm.* TO 'user1'@'%';
FLUSH PRIVILEGES;
4.远程登录:
mysql -u user1 -p123 -h 168.171.127.71