Thursday, August 26, 2021

Ubuntu 20.04 can not client remote MySQL Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

Error

Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server 

  • ติดตั้ง Ubuntu 20.04 ลง MySQL Server แต่ client ใช้ root remote มาไม่ได้
  • แก้ไข mysqld.cnf ใส่ bind-address=0.0.0.0
  • สั่ง sudo systemctl restart mysql.service แล้วมันก็ยัง remote ไม่ได้

# /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]

pid-file        = /var/run/mysqld/mysqld.pid

socket          = /var/run/mysqld/mysqld.sock

datadir         = /var/lib/mysql

log-error       = /var/log/mysql/error.log

bind-address            = 0.0.0.0

Solved

  • สร้าง user ใหม่เลยไม่ต้องใช้ root แล้วเพิ่มสิทธิ์ให้เทียบเท่า root

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;

REF

  • https://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server

No comments:

Post a Comment

Popular Posts