When using Mac computers, many developers will use databases such as MySQL for development and testing. However, when using MySQL, we may need to change the password of the database. Here's how to change your MySQL password on Mac.
Search for "Terminal" on Mac, or open Terminal through "Applications - Utilities - Terminal".
Enter the following command in the terminal to enter the mysql command line:
mysql -u root -p
The "-u" here represents the user name , the "root" behind is the default user name of MySQL. When using the "-p" parameter, MySQL will ask for a password.
Enter the current MySQL password. No characters will be displayed when entering. After pressing the Enter key, if the password is correct, you can enter the MySQL command line.
Enter the following command in the MySQL command line to change the password:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Here "root" is the user name, " "localhost" is the default host name of MySQL, and "new_password" is the new password, which can be replaced by yourself.
After completing the password change, enter the following command to exit the MySQL command line:
exit;
Use the new password to log in to MySQL to verify whether the password change is successful.
There may be other ways to change the MySQL password, but the above method is relatively simple and commonly used. When changing the password, you need to pay attention to the security of the password and do not use a password that is too simple or easy to guess to avoid unnecessary security risks.
The above is the detailed content of How to change mysql password on mac. For more information, please follow other related articles on the PHP Chinese website!