Home  >  Article  >  Database  >  How to change root password on mac mysql

How to change root password on mac mysql

PHPz
PHPzOriginal
2023-04-19 15:20:55998browse

In the process of using the MySQL database, it is often necessary to modify the password of the root user. Under macOS, to change the password of the MySQL root user, you can follow the steps below.

  1. Open the terminal application
  2. Enter the following command to stop the MySQL service:

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

  3. The method to start the MySQL server and ignore the permission table is as follows:

    sudo mysqld_safe --skip-grant-tables
  4. Open another terminal window , and enter the following command to connect to the MySQL server:

    mysql -u root
  5. Enter the following command to change the password of the root user:

    use mysql;
    update user set authentication_string=password('新密码') where user='root';
    flush privileges;

    Among them, the new password is the one you want to set password. It should be noted that in MySQL 5.7 and newer versions, the default password policy for the root user has been upgraded, and a password that meets the requirements needs to be set. Otherwise, an error may be reported.

  6. Finally, exit the MySQL server and enter the following command:

    exit
  7. Stop the MySQL service and enter the following command:

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

The above are the detailed steps for changing the MySQL root user password under macOS. If your MySQL version is different, the steps may be slightly different. In short, changing the MySQL root user password is not difficult, as long as you follow the correct steps.

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

Statement:
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