PHP Novice in the Mac system to build apache+mysql+php development environment (according to this blog to operate: http://my.oschina.net/joanfen/blog/171109?fromerr=xvCsafCe), After the installation configuration MySQL finished, log in MySQL, error: Mac error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using password:no), toss for a long time, finally resolved , jot down notes, Memo.
Workaround:
The first step: if the MySQL service is in progress, stop it.
The second step: start Mysqld_safe with administrator privilegesin the terminal, the command is as follows:
sudo --skip-grant-tables
The results of the implementation are as follows:
- -12t08: £ º+'/usr/local/mysql/data/ Lyqdemacbook-pro.local.err'. - -12t08: £ ºfrom/usr/local/mysql/data
The third step: do not close the current terminal window, create a new terminal window, enter the following command, return login MySQL
/usr/local/mysql/bin/mysql
After logging in, see the Welcome message:
Welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is Panax NotoginsengServer Version:5.7. -MySQL Community Server (GPL) Copyright (c) -, ., Oracle and/or its affiliates. All rights reserved. Oracle isA registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h' forHelp. Type'\c'To clear the current input statement.mysql>
Open the "MySQL" Database, SQL as follows:
Use MySQL;
See results:
for theget a quicker startup with-adatabase changedmysql
Then, update the root password, SQL as follows:
set authentication_string=password (' root ')where host='localhost ' and user='root';
Attention:
① Some versions of MySQL, the password may be stored in the password field, you can use "describe user;" command to view the following table structure and operation
The value of the ②authentication_string must be computed by the password function (password (' root '))
The results of the implementation are as follows:
1 1 Warning (0.011 1 1
Exit MySQL (Execute SQL statement: Exit)
The final step: Kill the Mysqld_safe process and restart the mysqld.
Problems that you may encounter
Log in to MySQL
/usr/local/mysql/bin/mysql-uroot-proot
At this point, if you perform an operation such as a query such as "show Databases;", you might have the following hints:
1820 using this statement.
Follow the prompts to enter the following SQL statement, which is to modify the root user's password to root:
' Root '@'localhost'root';
Results:
0 rows affected
At this point, the problem is resolved.
Reference: http://stackoverflow.com/questions/13480170/access-denied-for-mysql-error-1045
Mac system built apache+mysql+php development environment, after installing MySQL, login error: Mac error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)