kiscall

在安装好数据库时,默认是不能被远程主机连接的,解决这个问题很简单

1、设置允许连接的数据库IP:

sudo vim /etc/mysql/my.cnf

修改:

// 将
bind-address = 127.0.0.1
// 修改为
bind-address = 0.0.0.0
// 这是允许任意ip连接,也可以将其指定为固定ip

2、分发权限

登录MySQL

sudo mysql -u username -p password

赋权:

> grant all privileges on *.* to \'username\'@\'ip\' identified by \'password\';
> flush privileges; // 立即生效
// 第一个 * :数据库名
// 第二个 * :表名
// ip :连接数据库的远程主机的ip,任意ip写为 \'%\'
// username、password :远程主机连接的时候要使用的账号和密码。

重启MySQL:

sudo service mysql restart

分类:

技术点:

相关文章:

  • 2022-02-17
  • 2021-07-29
  • 2022-01-07
  • 2021-11-25
  • 2021-06-14
  • 2021-07-14
  • 2021-06-13
猜你喜欢
  • 2021-12-19
  • 2021-09-30
  • 2022-12-23
  • 2022-03-05
相关资源
相似解决方案