MySQL 1043: Bad handshake.

When facing the error 1043: Bad handshake from MySQL DB, follow these immediate actionable steps:

  1. Check MySQL Server Version Compatibility: Ensure that the MySQL client version is compatible with the MySQL server. You can find the version of your MySQL server by logging into your MySQL server and running:


SELECT VERSION();
For the client version, if you're using a command-line client, you can check its version by running:
mysql --version

  1. Verify User Credentials: Double-check the username and password being used to ensure they're correct. Typos or incorrect credentials are common issues.



  1. Inspect Network Issues: Verify there are no network issues preventing a proper connection between your client and the MySQL server. A simple ping to the server's hostname or IP address can verify network connectivity:


ping

  1. Check MySQL Server Configuration: Ensure that the MySQL server is configured to accept connections from your client's IP address. This involves checking the `bind-address` parameter in your MySQL server's configuration file (`my.cnf` or `my.ini`) and ensuring it's not set to `127.0.0.1` or it includes the IP range for your client.



  1. Review MySQL Server Logs: Look into the MySQL server logs for any additional information related to the handshake error. The error log location varies, but you can generally find it in `/var/log/mysql/error.log` or by checking the `log_error` system variable:


SHOW VARIABLES LIKE 'log_error';

  1. Increase Connection Timeout Values: If the issue might be related to network latency or heavy server load, increasing the connect timeout on the client side might help. For command-line clients, you can use:


mysql --connect-timeout=VALUE
Replace `VALUE` with a higher timeout value in seconds.

  1. Test with a Different Client: Try connecting to the MySQL server using a different client or tool. This can help determine if the issue is client-specific.



  1. Restart MySQL Service: Sometimes, simply restarting the MySQL service can resolve transient issues:


sudo systemctl restart mysql
Or, depending on your system:
sudo service mysql restart

Perform these steps in order to systematically diagnose and address the "Bad handshake" error with MySQL.

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