Question
Remote Mysql fail to connect - Tried everything I can think of.
So I am going to walk you through everything I have done since I created this. Since this is a test before I run it for production.
ssh in, change root password
adduser (new user added)
usermod -aG sudo (new user)
ufw limit ssh/tcp
ufw limit (new ssh ip/tcp)
ufw allow 3306
edit /etc/ssh/sshd_config (change ssh port and disallow root login)
systemctl restart ssh
(disconnect and reconnect via port 22 to make sure ssh isn’t listening. Try new port and make sure root doesn’t allow login.)
Sign in via new credentials.
ufw enable
ufw status (verify 3306 is open)
apt update
apt upgrade
apt install mysql-server
mysql (create database)
mysql (create user -> create user “user”@“%” identified by “password”; )
mysql (grant all on database.* to “user”@“%”;)
mysql flush privileges;
edit /etc/mysql/mysql.conf.d/mysqld.cnf
set bind-address to database server ip (save & exit)
systemctl restart mysql
netstat -ln | grep 3306 (verify mysql is listening)
attempt to connect using https://www.rainbowspuppiessunshine.com/tools/dbtest/index.php connection tool.
I get an error (111 failed to connect)
I have also tried securing the connection via a few guides and still no luck. I tried an alternate connection tool and it said refused to connect.
so I disabled the firewall (since this is just a test server)
ufw disable
ufw status
(verified it was disabled)
tried the connection again, still nothing.
refused to connect and failed to connect
there is no cloud firewall unless it’s allocated by digital ocean.
I have tried this various times and on various droplets. If I use the mysql one clicks I can’t even change the bind address without getting a fail error when mysql reloads.
I am out of ideas here. Any help or ideas would be appreciated.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×