✅ STEP-BY-STEP FIX (Hosting Provider Side)
🔐 1. Open Port 3306 in the Firewall
If using firewalld
(CentOS/RHEL):
sudo firewall-cmd --permanent --add-port=3306/tcp
sudo firewall-cmd --reload
If using ufw
(Ubuntu/Debian):
sudo ufw allow 3306/tcp
sudo ufw reload
🧠 This opens port 3306 so external IPs can reach it.
⚙️ 2. Configure MySQL to Accept Remote Connections
Open my.cnf
or mysqld.cnf
:
sudo nano /etc/my.cnf # Common on CentOS
# or
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf # Common on Ubuntu
Find this line:
bind-address = 127.0.0.1
Change to:
bind-address = 0.0.0.0
💡 This makes MySQL accept connections from all IPs, not just localhost.
Then restart MySQL:
# CentOS/RHEL
sudo systemctl restart mysqld
# Ubuntu/Debian
sudo systemctl restart mysql
🧑💻 3. Make Sure the MySQL User Has Remote Access
In MySQL shell:
GRANT ALL PRIVILEGES ON tsgbsite_tsgb_db.* TO 'tsgbsite_tsgb_us'@'%' IDENTIFIED BY 'YAqmBg9UPB^T';
FLUSH PRIVILEGES;
🛠️ This allows the user to connect from any host.
🧪 4. Test It Yourself
From your Node.js app or terminal:
mysql -h 103.163.246.85 -u tsgbsite_tsgb_us -p
# Enter password when prompted
If the connection succeeds, you're all set!
📝 Summary You Can Send to Hosting Support
🔧 Ask your hosting provider to do these:
- Open port
3306
in the firewall (for incoming TCP).- Set MySQL
bind-address
to0.0.0.0
(not127.0.0.1
).- Restart MySQL service after the change.
- Ensure MySQL user has privileges from
%
(any host).