Recover MySQL root password

If you have lost the MySQL root password, or just don’t remember it, don’t worry, follow the step by step for you to retrieve it

  1. Stop the MySQL service if it is running “/etc/init.d/mysql stop”
  2. Up the Server “skiping” the layer responsible for checking the user privileges mysqld_safe-skip-grant-tables , remembering , when you start the server with this option, it will accept any user to connect to database MySQL database with full access to all the databases, then to inhibit other people from connecting to the server during the maintenance period, I suggest you use the following command to start the server  mysqld_safe – skip-grant-tables – skip-networking. In this case the server not accept connections over TCP/IP
  3. Connect to server with the command mysql -u anything
  4. Enter update mysql.user set Password=PASSWORD(‘new-password’) WHERE User=’root’
  5. Stop the server whit the command  mysqladmin -u qualquer_coisa shutdown and start again with without skiping commands mysqld_safe 
Liked? Help and Share!
This entry was posted in install, MySQL, password. Bookmark the permalink.
  • Boa Marcelo, quem nunca instalou um banco MySql e não se ferrou por não lembrar mais a senha. 🙂

    Valeu pelas dicas.
    Abraço.

  • Hans

    Tava precisando de algo parecido estes dias, só que era pra Postgres. Felizmente já resolvi (não posto a solução aqui pq tah em outra máquina).

    Abraço

  • Grace

    valeu 😉

  • Carlos Borges

    Cristian Cardoso :
    Boa Marcelo, quem nunca instalou um banco MySql e não se ferrou por não lembrar mais a senha.
    Valeu pelas dicas.
    Abraço.

    Faço das palavras do Cristian as minhas!!

    • José Alves

      Faço das palavras suas e do Cristian as minhas

  • That’s an excellent nugget! I think resetting the root password of MySQL can be done automatically from the cPanel interface when you change the password of your hosting account.

    • marceloaltmann

      Yes, but if you do a hands free installation you don’t have cPanel.
      Feel free to visit regularly

  • you can recover it with the debian-sys-maint user

  • valter