I have a VPS server on which I have MySQL database. My /etc/mysql/conf.d/mysql.cnf
:
[mysql]
port = 5231
bind-address = 0.0.0.0
Then I create a brand new user:
CREATE user 'dbuser'@'%' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES
After that, sudo systemctl restart mysql
. As the result I can connect from my VPS server with localhost
domain but cannot connect from my local machine e.g. with PHPStorm. I use totally the same credentials for PHPStorm but I got “Connection refused”. Probably I guess because of firewall. Unfortunately I didn’t even add any rule to firewall. However I did some rule like ufw allow from my_local_machine_ip to any 5231
Then the error was: “Connection timed out”
Version: mysql Ver 8.0.39-0ubuntu0.24.04.2 for Linux on x86_64 ((Ubuntu))
Credentials with which I tried to connect to database from PHPStorm:
Host: "VPS_IP_ADDRESS"
Port: "5321"
User: "dbuser"
Password: "strong_password"
Database: "my_database"
Finally I want to configure connection to MySQL with ufw
only for my local machine’s IPv4 address
Tried to connect to database from local machine unfortunately I couldn’t.
2