Home > Database > Mysql Tutorial > How Can I Reset My MySQL Root Password in Ubuntu?

How Can I Reset My MySQL Root Password in Ubuntu?

DDD
Release: 2024-12-16 19:12:17
Original
328 people have browsed it

How Can I Reset My MySQL Root Password in Ubuntu?

Resetting or Changing the MySQL Root Password

If you're facing difficulties changing the MySQL root password and username in Ubuntu server, consider the following steps:

  1. Stop the MySQL Service:

    sudo /etc/init.d/mysql stop
    Copy after login
  2. Start the MySQL Configuration:

    sudo mysqld --skip-grant-tables &
    Copy after login
  3. Connect to MySQL as Root:

    mysql -u root mysql
    Copy after login
  4. For MySQL Versions Below 8.0:

    • Update the password:

      UPDATE mysql.user SET Password = PASSWORD('YOURNEWPASSWORD') WHERE User = 'root';
      Copy after login
    • Flush privileges:

      FLUSH PRIVILEGES;
      Copy after login
      Copy after login
      Copy after login
  5. For MySQL Versions 8.0 and Above:

    • Flush privileges:

      FLUSH PRIVILEGES;
      Copy after login
      Copy after login
      Copy after login
    • Alter root user:

      ALTER USER 'root'@'localhost' IDENTIFIED BY 'YOURNEWPASSWORD';
      Copy after login
    • Flush privileges again:

      FLUSH PRIVILEGES;
      Copy after login
      Copy after login
      Copy after login
  6. Cleanup:

    • Kill the temporary MySQL process:

      sudo killall -9 mysqld
      Copy after login
    • Start the normal daemon:

      sudo service mysql start
      Copy after login

Remember, this method is not considered the most secure, but it should get the job done. PhpMyAdmin will be updated automatically if it's configured to connect to the MySQL server using the updated credentials.

The above is the detailed content of How Can I Reset My MySQL Root Password in Ubuntu?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template