Symptoms: Communications link failure, Connection refused, Access denied for user, MySQL connection error
Possible Causes
- The MySQL service is not running
- Wrong database username or password
- bind-address is set to localhost only (remote connections are refused)
- The firewall is blocking port 3306
Step-by-Step Fix
Step 1
Check whether the MySQL service is running
sudo systemctl status mysqlStep 2
Test the username and password directly against MySQL
mysql -u kullanici -p -h 127.0.0.1 veritabani_adiStep 3
If you need remote connections, set bind-address to 0.0.0.0 in /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0Step 4
Open port 3306 in the firewall
sudo ufw allow 3306/tcpStep 5
Grant the MySQL user remote access privileges
GRANT ALL PRIVILEGES ON veritabani.* TO 'kullanici'@'%' IDENTIFIED BY 'sifre'; FLUSH PRIVILEGES;