MySQL 1134: Connection failed.

  1. Check MySQL Server Status: First, ensure that the MySQL server is running. You can do this by executing the command:



sudo systemctl status mysql

If the server is not running, start it with:

sudo systemctl start mysql

  1. Verify Network Connectivity: Check if the MySQL server is reachable over the network using the `ping` command followed by the server's IP address or hostname.



ping [MySQLServerIP/Hostname]

  1. Check Firewall Settings: Ensure the firewall is not blocking the connection to MySQL. You can check if the MySQL port (default is 3306) is open by using:



sudo ufw status

If it's blocked, allow it with:

sudo ufw allow 3306

  1. Inspect MySQL User Permissions: Verify that the user has the correct permissions and is allowed to connect from the host. Log into MySQL from a terminal or command prompt that has access and run:



SHOW GRANTS FOR 'yourusername'@'yourhost';

Replace `'yourusername'@'yourhost'` with the actual username and host you're connecting from.

  1. Review the MySQL Error Log: Check the MySQL error log for any specific messages related to the connection issue. The location of the log file can vary, but you can find it by checking the MySQL configuration file or running:



sudo grep 'log_error' /etc/mysql/my.cnf

Then view the log with:

tail -f /path/to/mysql/error.log

  1. Increase the max_connections Setting if Necessary: If the server is reaching its connection limit, increase it by editing the MySQL configuration file (`/etc/mysql/my.cnf` or `/etc/mysql/mysql.conf.d/mysqld.cnf`) and setting:



[mysqld]
max
connections = [newlimit]

Apply the change by restarting MySQL:

sudo systemctl restart mysql

  1. Check for IP Binding Issues: Ensure MySQL is not bound to a specific IP address. Check the `bind-address` directive in the MySQL configuration file (`/etc/mysql/my.cnf` or its included files). If it's set to an IP address other than the one you're connecting from or `0.0.0.0` (for listening on all interfaces), you may need to change it.



  1. Test MySQL Connection Locally: If you have access to the server, try connecting to MySQL locally using the command line to rule out network issues:



mysql -u [your_username] -p

These steps should help identify or resolve the "Error 1134: Connection failed" issue with your MySQL database.

Master

MySQL

in Minutes — Grab the Ultimate Cheatsheet

(Perfect for DevOps & SREs)

Most-used commands
Real-world configs/examples
Handy troubleshooting shortcuts
Your email is safe with us. No spam, ever.

Thankyou for your submission

We have sent the cheatsheet on your email!
Oops! Something went wrong while submitting the form.

MySQL

Cheatsheet

(Perfect for DevOps & SREs)

Most-used commands
Your email is safe with us. No spam, ever.

Thankyou for your submission

We have sent the cheatsheet on your email!
Oops! Something went wrong while submitting the form.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid