Mysql Connection problem

chez123

New member
Joined
Jan 31, 2017
Messages
4
hello,
i have problem with connection from other server.
root@second:~# mysql -u da_admin -p --host=xxxxxxx -p 3306
Enter password:


ERROR 2003 (HY000): Can't connect to MySQL server on 'xxxxx' (110)

on server xxxxx I setup bind address in /etc/my.cnf in [mysqld] directive. both servers accepts connections on port 3306
 
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
 
Open outgoing port 3306 on the server that needs external access, and comment out bind-address (if exists) in /etc/my.cnf

if using csf
Code:
tcp|out|d=3306|d=The.IP.of.the.other.server
in /etc/csf/csf.allow
 
@Peter Laws Server is running on Ubuntu and here are content of my.cnf

```
[mysqld]
max_allowed_packet=64M
local-infile=0
innodb_file_per_table

[client]
socket=/usr/local/mysql/data/mysql.sock
```
 
Open outgoing port 3306 on the server that needs external access, and comment out bind-address (if exists) in /etc/my.cnf

if using csf
Code:
tcp|out|d=3306|d=The.IP.of.the.other.server
in /etc/csf/csf.allow
So I should open 3306 in iptables rules. Is that right one?
 
Ok Can you please send me a best blog to set that 3306 port in iptables since I have not much experience for that. Thank you so much
 
LMGTFY

Ignore any INPUT lines

Just add -d flag for the destination IP, so if 35.89.89.39 is the remote MySQL
Code:
iptables -t filter -A OUTPUT -p tcp -d 35.89.89.39 --dport 3306 -j ACCEPT
 
Screenshot 2020-12-08 at 9.01.18 AM.png


Could you please take a look at it? I just tried to run those iptables commands and tried to connect again but failed again. Seems 3306 still off now. Please advise me. Thank you
 
You need to add the IP to the user, to allow external HOSTS...... Go to the MySQL section in Directadmin, click the user, then add a HOST and add the IP
 
Screenshot 2020-12-08 at 9.16.03 AM.png

I added VideoGuruSql user to the DB server by typing those commands:

```
CREATE USER 'VideoGuruSql'@'app.server.ip' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON db_name.* TO 'VideoGuruSql'@'app.server.ip';
FLUSH PRIVILEGES;
exit;
```
 
I have a question. Do I need to open port 3306 on the app server or DB server? :) Please let me know. I tried to run iptables commands on App server. Thank you
 
iptables -t filter -A OUTPUT -p tcp -d DB.Server.IP.Address --dport 3306 -j ACCEPT

Is that right one? on app server?
 
Back
Top