Linux 查找 MySQL 配置文件
1.找到 MySQL 的位置
which mysql # /usr/bin/mysql
2.执行查找命令
/usr/bin/mysql --verbose --help|grep -A 1 \'Default options\'
# /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf 为MySQL执行配置文件的先后顺序
Linux 设置 MySQL 允许外网访问
1.在 /etc/my.cnf 配置文件 [mysqld] 中增加 port=3306 bind-adress=0.0.0.0
vim /etc/my.cnf
port=3306
bind-address=0.0.0.0
2.登录,设置
>>> mysql -u root -p 123456
>>> use mysql
>>> select user, host from user;
>>> update user set host=\'%\' where user = \'root\';
3.授权用户具体权限
授权任意主机(@\'%\')通过root用户(\'root\'@)用123456密码(identified by \'123456\')连接到mysql服务器
>>> grant all privileges on *.* to \'root\'@\'%\' identified by \'123456\' with grant option;
>>> flush privileges;
4.重启 MySQL 生效
>>> systemctl restart mysqld