Solution for mac os 10.13 installing mysql 5.7.21 and encountering Access denied for user 'root'@'localhost' (using password: YES)

1. After the installation is complete, type in the terminal:

$ mysql --version

- The display version number is normal. If the command not found is displayed, enter the following in the terminal. "/usr/local/mysql/bin/mysql" is the default installation path of mysql:

$ cd /usr/local/bin/

$ sudo ln -fs /usr/local/mysql/bin/mysql mysql

2. Restart the mysql service (the system is easy to set);

3. Terminal input:

$ mysql -u root -p

4. Enter the initial random password, such as:

A temporary password is generated for root@localhost: Wt/oJMbZs5rg

The login is successful as shown below:

5. The terminal executes the following three sentences (the trailing semicolon cannot be lost):

SET PASSWORD = PASSWORD('your new password');

ALTER USER ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER;

flush privileges;

After the modification is successful, you can log in with the new password~~~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325628742&siteId=291194637