Get the App
SLTechnology News&Howtos  ›  Database  › 

How to solve forgetting mysql password in MAC

Shulou Source: shulou.com Published: 2022-05-31 19:33:41 11月13日 Update

This article shows you how to forget the mysql password in MAC, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Shut down the mysql server

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

two。 Enter the directory

Cd / usr/local/mysql/bin

3. Get permission

Sudo su

4. Restart the server

. / mysqld_safe-- skip-grant-tables &

5.control + D quit Editing

6. Configure short commands

Alias mysql=/usr/local/mysql/bin/mysql

7. Enter mysql command mode

Mysql

8. Access to mysql database

Use mysql

9. Get permission to change

Flush privileges

10. Reset password

Set password for 'root'@'localhost'=password (' new password')

Case 2: if you often use home-brew installation to install software, you only need to change the path in the above steps. The default installation of mysql is / usr/local/Cellar/mysql/5.7.16, and you only need to change steps 1, 2 and 6 above / usr/local/mysql to / usr/local/Cellar/mysql/5.7.16.

Case 3: this situation belongs to the relatively crappy situation. After downloading mysql, I forgot this thing for a long time, and then downloaded another one. I found that the database downloaded first prompted me to enter the password directly. Then according to case 1 or case 2, the input command cannot be modified successfully. It is also useless to modify my.cnf (now my-default.cnf) in accordance with the method introduced online. If you unfortunately encounter this situation, please follow these steps

1. Uninstall mysql

Sudo rm / usr/local/mysql sudo rm-rf / usr/local/var/mysql sudo rm-rf / usr/local/mysql* sudo rm-rf / Library/StartupItems/MySQLCOM sudo rm-rf / Library/PreferencePanes/My* vim / etc/hostconfig and removed the line MYSQLCOM=-YES-rm-rf ~ / Library/PreferencePanes/My* sudo rm-rf / Library/Receipts/mysql* sudo rm-rf / Library/Receipts/MySQL* sudo rm-rf / var/db/receipts/com.mysql.* the above is how to resolve the forgotten mysql password in MAC Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Situations passwords commands steps content skills data databases servers permissions knowledge services input concise successful concise unfortunately things just Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia Huawei Apple vpn