221 words
1 minutes
Database connection failed due to Host 'srv.template.com' is not allowed to connect to this MariaDB server

Lỗi#

“Database connection failed due to Host ‘srv.template.com’ is not allowed to connect to this MariaDB server”

Nguyên nhân gốc#

Máy chủ MariaDB (ở 120.179.190.160) không cho phép user ad_sksksksks truy cập từ hostname srv.template.com (có thể là host chạy web https://dsjjsjsjsjsj.vn).

Dù bạn nhập đúng mật khẩu, thì MySQL vẫn từ chối kết nối nếu user@host chưa được cấp phép.


Cách xử lý nhanh (bạn có root VPS)#

Giả sử bạn có quyền root trên máy chủ MariaDB ở 103.179.190.160, thực hiện như sau:


Bước 1: SSH vào máy chủ MariaDB#

Terminal window
ssh root@103.179.190.160

Bước 2: Mở MySQL/MariaDB#

Terminal window
mysql -u root -p

Bước 3: Cấp quyền truy cập từ xa cho user admin_lalalalalaly#

Trường hợp 1: Bạn biết chính xác hostname là srv.template.com:

GRANT ALL PRIVILEGES ON public_dkbeauty.* TO 'admin_lalalalalaly'@'srv.template.com' IDENTIFIED BY 'XAKJSLDJASLJDLASD';

Trường hợp 2: Cấp quyền cho tất cả IP (ít bảo mật, chỉ nên dùng tạm):

GRANT ALL PRIVILEGES ON public_dkbeauty.* TO 'admin_lalalalalaly'@'%' IDENTIFIED BY 'XAKJSLDJASLJDLASD';

Sau đó:

FLUSH PRIVILEGES;

Bỏ qua.#

Bước 4: Cho phép MariaDB lắng nghe kết nối từ xa#

Mở file cấu hình:

Terminal window
nano /etc/mysql/mariadb.conf.d/50-server.cnf

Tìm dòng:

bind-address = 127.0.0.1

→ Sửa thành:

bind-address = 0.0.0.0

Rồi khởi động lại MariaDB:

Terminal window
systemctl restart mariadb

Bước 5: Mở firewall (nếu cần)#

Nếu bạn dùng ufw (tường lửa Ubuntu):

Terminal window
ufw allow 3306

Hoặc mở cụ thể cho IP chạy srv.template.com:

Terminal window
ufw allow from <IP-cua-srv.template.com> to any port 3306

Bạn có thể tra IP của srv.template.com bằng:

Terminal window
nslookup srv.template.com

Bước 6: Truy cập lại BigDump#

Vào lại: https://xkxkxkxkkxx.vn/bigdump/bigdump.php

→ Chạy lại quá trình import