Mac login MySQL error 1045

Time:2020-3-31

Mac login MySQL error 1045 (28000): access denied for user ‘root’ @ ‘localhost’ (using password: no)

Environmental Science

MySQL version: 5.7.12
Operating system: OSX 10.14.6 (18g84)
Installation file:. DMG download installation package (I selectedMacOS 10.14 (x86, 64 bit), DMG ArchiveVersion download of)

Mysql-5.7.26-mac OS 10.14-x86_.dmg

Step 1

Close the MySQL service. Whether you open MySQL service or not, you need to run the following commands to be on the safe side.

sudo /usr/local/mysql/support-files/mysql.server stop

(Note: I have reported an error here: error! MySQL server PID file could not be found! I can directly enter MySQL in the system preference settings (at the bottom) and close it. The second step is the same.)

Step 2

Start MySQL in safe mode.

sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables

(the second step seems to be difficult, as follows:

1. Enter the command to add MySQL path in the terminal:

   PATH="$PATH":/usr/local/mysql/bin    

Note: as long as you find this kind of error reporting MySQL: command not found, you can use the path code, and then enter the command line of error reporting before you

2. Get administrator permission

Sudo Su (enter your notebook password)

3. Log in to MySQL directly over the permission table

​ mysqld_safe –skip-grant-tables –skip-networking &

In security mode, you can directly open MySQL command line window without password.

Step 3

Create a new terminal and change the root password

Note here that the password field in mysql.user table has been changed to: authentication [u string] compared with the previous version in 5.7

Enter the following commands one by one, change the root password and exit. If you continue to use password, an error will be reported. This field cannot be found. New password: 12345

mysql -u root
UPDATE mysql.user SET authentication_string=PASSWORD('12345') WHERE User='root';

take12345Change to your new password. After running the above command, the password of root will be changed to the password you set

test

Run the following command to test if the password was modified successfully.

mysql -u root -p

Then enter your new password.

If the input is correct, the MySQL command line window should appear, as follows:

mysql> 

Reference resources

[MySQL changes root password for Mac error: error 1045 (28000): access denied for user ‘root’ @ ‘localhost’ (using password: no)

Recommended Today

Configure Apache to support PHP in the Apache main configuration file httpd.conf Include custom profile in

In Apache’s main configuration file / conf/ http.conf Add at the bottom Include “D:workspace_phpapache-php.conf” The file path can be any In D: workspace_ Create under PHP file apache- php.conf file Its specific content is [html] view plain copy PHP-Module setup LoadFile “D:/xampp/php/php5ts.dll” LoadModule php5_module “D:/xampp/php/php5apache2_2.dll” <FilesMatch “.php$”> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch “.phps$”> SetHandler application/x-httpd-php-source </FilesMatch> […]