Home >Database >Mysql Tutorial >How to modify the MySQL root account under mac
Under the Mac operating system, if you need to modify the MySQL root account, you can follow the steps below.
Step 1: Stop the MySQL service
Open the terminal and enter the following command to stop the MySQL service:
sudo /usr/local/mysql/support-files/mysql.server stop
Step 2: Restart the MySQL service and skip permission authentication
Enter the following command to restart the MySQL service and skip permission authentication:
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
Note: If the "command not found" error occurs, please confirm whether the MySQL installation path is /usr/local/mysql.
Step 3: Log in to MySQL as root
Open another terminal window and enter the following command to log in to MySQL as root:
mysql -u root
Tip: If "Permission denied" error, please check whether you have successfully skipped permission authentication.
Step 4: Modify the root account password
After logging in to MySQL, enter the following command to modify the root account password:
mysql>use mysql;
mysql>update user set password=password(' newpassword') where user='root';
mysql>flush privileges;
Among them, "newpassword" is the new password you need to set.
Step 5: Restart the MySQL service
Enter the following command to restart the MySQL service:
sudo /usr/local/mysql/support-files/mysql.server start
Congratulations, you have now successfully changed the MySQL root account password. Through the above steps, you can easily modify the MySQL root account under the Mac operating system.
The above is the detailed content of How to modify the MySQL root account under mac. For more information, please follow other related articles on the PHP Chinese website!