Home > Database > Mysql Tutorial > body text

How to solve the problem of forgetting mysql password on mac?

青灯夜游
Release: 2020-10-12 09:50:59
Original
7317 people have browsed it

Solution: First open the terminal and enter the command "mysql -u root"; then enter the command "UPDATE mysql.user SET authentication_string=PASSWORD('new password') WHERE User='root';".

How to solve the problem of forgetting mysql password on mac?

(Recommended tutorial: mysql video tutorial)

Log in mysql on mac and forget your password Solution

1. Open the terminal and enter the command: cd /usr/local/mysql/bin

2 , mysql -uroot -p, use this command to log in and report an error message:

Error message:

Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Copy after login

3. Open the terminal and enter: sudo mysqld_safe --skip-grant-tables

Output

Password:
Logging to '/usr/local/mysql/data/localhost.err'.2018-10-10T03:21:40.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
Copy after login

4. Open a new terminal and enter: mysql -u root , you will see the following output.

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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 respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
Copy after login

5. Enter use mysql in the terminal and the display will be as follows

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
Copy after login

6. Change password: UPDATE mysql.user SET authentication_string=PASSWORD ('Your password') WHERE User='root';

Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 1
Copy after login

Related recommendations:php training

The above is the detailed content of How to solve the problem of forgetting mysql password on mac?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!