The following methods are pro-test effective, the process using the tool only Mac terminal without workbench;
When we connect to the MySQL database via the terminal we will see this information:
ERROR 1045: Access denied for user: ‘[email protected]‘ (Using password: NO)
Or
ERROR 1045: Access denied for user: ‘[email protected]‘ (Using password: YES)
One way to resolve the above error is to reset our MySQL root password.
1. In the terminal enter the following command to close the running MySQL, if MSYQL is not running can skip, need to enter MySQL password. If the MySQL password is forgotten, you can close it directly through system Preferences!
`/usr/local/mysql/bin/mysqladmin -u root -p shutdown`
2. Go to the MySQL bin directory to execute the following command
$ cd /usr/local/mysql/bin$ sudo su
Then enter the administrator password to see
We then enter the following command to run MySQL in safe mode
sh-3.2#./mysqld_safe --skip-grant-tables &
Run the end we turn on Mac System Preferences, select MSYQL, we'll find MySQL rerun
Back to Terminal click Command + N to reopen a terminal
Input
mysql -u -root
That's when we don't need a password to get into MySQL.
Your MySQL connection id is 57Server version: 5.7.10 MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>
Note: There are times when it will not come in, this time can try to restart the Mac computer, the specific reason I am not clear.
3. Change the root password
First execute the following command in order to be able to modify any password
mysql> FLUSH PRIVILEGES;
Then execute the SQL statement that modifies the password, where the qsd19001008 can replace the password you want to change.
mysql> SET PASSWORD FOR [email protected]‘localhost‘ = PASSWORD(‘qsd19001008‘);
If your sub account can log in msyql you can also try the following methods
mysql>UPDATE mysql.user SET Password=PASSWORD(‘newpwd‘) WHERE User=‘root‘;
Or
mysql>USE mysql UPDATE user SET Password = PASSWORD(‘newpwd‘) WHERE Host = ‘localhost‘ AND User = ‘root‘;
Or
mysql>USE mysql UPDATE user SET Password = PASSWORD(‘newpwd‘) WHERE Host = ‘%‘ AND User = ‘root‘;
Last Refresh
FLUSH PRIVILEGES;
Control+d launch MySQL, and then close the Safe Mode database, here to enter you just set the data password just fine
/usr/local/mysql/bin/mysqladmin -u root -p shutdown
So far, you've recovered your MySQL password.
Start the MySQL database normally and enter the password you just set qsd19001008
/usr/local/mysql/share/mysql.server start
If the above command does not execute, the same as in System Preferences to open the MySQL server.
Finally execute the following Terminal command, and then enter the password that you just set qsd19001008 we can get to MySQL properly.
$mysql -u root -p
MySQL root password forgetting or permissions error resolution on Mac