Home >Database >Mysql Tutorial >Quick solution for Mysql forgotten Root password or wrong permissions on MAC_MySQL
I have been messing around with mantis recently and found that there was always an error connecting to mysql, so I changed the root permissions and couldn't log in.
Let me share with you the most convenient method to restore root permissions and change root password.
1: Install mysql workbench. Direct operation via visual interface.
2: Apple->System Preferences->Click mysql at the bottom and close the mysql service in the pop-up page
3: Enter the terminal
Enter:
cd /usr/local/mysql/bin/
After pressing enter, log in with administrator rights
sudo su
Enter the following command after pressing Enter to disable the mysql verification function
./mysqld_safe --skip-grant-tables &
After pressing Enter, mysql will automatically restart. After restarting, enter mysql workbench, create a connection at will, and then fill in root as the user name (note that the password will not be verified here, so fill in an existing account).
Create another server administration and select the connection just created.
Double-click server administration
Click security on the left, and you can see all user permission tables on the right. You can do whatever you want at this time
Here are some instructions:
User permissions table
Limit Connectivity to Hosts Matching indicates the login address limit, which is the IP address when logging in. ‘%’ represents any
Adminstrative Roles are permissions. If you find that your root does not have administrator permissions, click this tab to check them all
The following are other commands
/mysqladmin -u root -p password 123 //更改root用户密码 /mysql -uroot -p //root用户登录mysql
The following are common errors
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
It means your root permissions are not enough, you can refer to the above steps to set permissions
Access denied; you need (at least one of) the SUPER privilege(s) for this operation
It means your root permissions are not enough, you can refer to the above steps to set permissions
The above is the quick solution for Mysql forgotten Root password or wrong permissions on MAC introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support of the website!