whkzm

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

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2021-11-30
  • 2022-01-11
  • 2021-08-18
猜你喜欢
  • 2021-06-13
  • 2021-09-12
  • 2022-01-28
  • 2021-07-15
  • 2021-11-30
  • 2021-04-21
  • 2021-11-30
相关资源
相似解决方案