Solved connection problem after MySQL installed on macOS

I downloaded MySQL from official website, I got this error message when I tried to connect MySQL server by Sequel Pro after it was installed.

Image

I had no idea when I first got this, after google the problem, I find the solution.


For fresh installation

This issue is because you're using the new Strong Password Encryption which is a new feature in MySQL 8, if you installed MySQL 8 using the .dmg file, you can go to System Preferences > MySQL and then click on Initialize Database type your password and select the second option Use Legacy Password Encryption.

  1. Open MySQL from System Preferences, then click on Initialize Database
  2. Type your new password
  3. Choose 'Use legacy password'
  4. Restart the MySQL Server
  5. Now connect the MySQL Server again

For non-fresh installation

For non-fresh installation, you can change the encryption of the password like this:

ALTER USER 'yourusername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';

Related links