unable to reset root password of mysql












27















I need to reset the root password of my local mysql installation but it woudln't let me. I've tried this:



$ sudo /etc/init.d/mysql stop
* Stopping MySQL database server mysqld [ OK ]
[1]- Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
[2]+ Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
reg@regDesktopHome:~$ sudo mysqld --skip-grant-tables &
[1] 13651
reg@regDesktopHome:~$ 140627 19:02:02 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.

reg@regDesktopHome:~$ mysql -u root mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
reg@regDesktopHome:~$ sudo mysql -u root mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[1]+ Exit 1 sudo mysqld --skip-grant-tables


How can I get the password reset?
edit 1
I got this:



$ ps ax| grep mysql
16515 ? Ssl 0:00 /usr/sbin/mysqld
16551 pts/23 S+ 0:00 grep --color=auto mysql
reg@regDesktopHome:~/semios/v3upgrade$ sudo kill -9 16515
reg@regDesktopHome:~/semios/v3upgrade$ ps ax| grep mysql
16678 ? Ssl 0:00 /usr/sbin/mysqld
16715 pts/23 S+ 0:00 grep --color=auto mysql
reg@regDesktopHome:~/semios/v3upgrade$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


looks like a process is automatically restarting mysql as soon as I kill it...










share|improve this question





























    27















    I need to reset the root password of my local mysql installation but it woudln't let me. I've tried this:



    $ sudo /etc/init.d/mysql stop
    * Stopping MySQL database server mysqld [ OK ]
    [1]- Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
    [2]+ Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
    reg@regDesktopHome:~$ sudo mysqld --skip-grant-tables &
    [1] 13651
    reg@regDesktopHome:~$ 140627 19:02:02 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.

    reg@regDesktopHome:~$ mysql -u root mysql
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    reg@regDesktopHome:~$ sudo mysql -u root mysql
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    [1]+ Exit 1 sudo mysqld --skip-grant-tables


    How can I get the password reset?
    edit 1
    I got this:



    $ ps ax| grep mysql
    16515 ? Ssl 0:00 /usr/sbin/mysqld
    16551 pts/23 S+ 0:00 grep --color=auto mysql
    reg@regDesktopHome:~/semios/v3upgrade$ sudo kill -9 16515
    reg@regDesktopHome:~/semios/v3upgrade$ ps ax| grep mysql
    16678 ? Ssl 0:00 /usr/sbin/mysqld
    16715 pts/23 S+ 0:00 grep --color=auto mysql
    reg@regDesktopHome:~/semios/v3upgrade$ mysql -u root
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


    looks like a process is automatically restarting mysql as soon as I kill it...










    share|improve this question



























      27












      27








      27


      24






      I need to reset the root password of my local mysql installation but it woudln't let me. I've tried this:



      $ sudo /etc/init.d/mysql stop
      * Stopping MySQL database server mysqld [ OK ]
      [1]- Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
      [2]+ Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
      reg@regDesktopHome:~$ sudo mysqld --skip-grant-tables &
      [1] 13651
      reg@regDesktopHome:~$ 140627 19:02:02 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.

      reg@regDesktopHome:~$ mysql -u root mysql
      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
      reg@regDesktopHome:~$ sudo mysql -u root mysql
      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
      [1]+ Exit 1 sudo mysqld --skip-grant-tables


      How can I get the password reset?
      edit 1
      I got this:



      $ ps ax| grep mysql
      16515 ? Ssl 0:00 /usr/sbin/mysqld
      16551 pts/23 S+ 0:00 grep --color=auto mysql
      reg@regDesktopHome:~/semios/v3upgrade$ sudo kill -9 16515
      reg@regDesktopHome:~/semios/v3upgrade$ ps ax| grep mysql
      16678 ? Ssl 0:00 /usr/sbin/mysqld
      16715 pts/23 S+ 0:00 grep --color=auto mysql
      reg@regDesktopHome:~/semios/v3upgrade$ mysql -u root
      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


      looks like a process is automatically restarting mysql as soon as I kill it...










      share|improve this question
















      I need to reset the root password of my local mysql installation but it woudln't let me. I've tried this:



      $ sudo /etc/init.d/mysql stop
      * Stopping MySQL database server mysqld [ OK ]
      [1]- Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
      [2]+ Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
      reg@regDesktopHome:~$ sudo mysqld --skip-grant-tables &
      [1] 13651
      reg@regDesktopHome:~$ 140627 19:02:02 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.

      reg@regDesktopHome:~$ mysql -u root mysql
      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
      reg@regDesktopHome:~$ sudo mysql -u root mysql
      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
      [1]+ Exit 1 sudo mysqld --skip-grant-tables


      How can I get the password reset?
      edit 1
      I got this:



      $ ps ax| grep mysql
      16515 ? Ssl 0:00 /usr/sbin/mysqld
      16551 pts/23 S+ 0:00 grep --color=auto mysql
      reg@regDesktopHome:~/semios/v3upgrade$ sudo kill -9 16515
      reg@regDesktopHome:~/semios/v3upgrade$ ps ax| grep mysql
      16678 ? Ssl 0:00 /usr/sbin/mysqld
      16715 pts/23 S+ 0:00 grep --color=auto mysql
      reg@regDesktopHome:~/semios/v3upgrade$ mysql -u root
      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


      looks like a process is automatically restarting mysql as soon as I kill it...







      password mysql reset






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 28 '14 at 4:40







      cerr

















      asked Jun 28 '14 at 2:05









      cerrcerr

      43641129




      43641129






















          6 Answers
          6






          active

          oldest

          votes


















          43














          First please try using



          mysql -u root -p


          and enter your password (if you remember) at the prompt to login as the sql-root user (note the switch -p is for password).



          If you really have to reset your root password for mysql, here's an easy way - reconfigure the package with dpkg-reconfigure.



          Easy steps to reset mySQL root password:





          1. Check the version of your mysql-server;



            apt-cache policy mysql-server


            and see for the line which shows the installed version among other information. e.g. for my install it's:



            Installed: 5.5.37-0ubuntu0.12.04.1


            (From this I know that I have mysql-server-5.5 installed in my system.)




          2. Start the reconfiguration with:



            sudo dpkg-reconfigure mysql-server-*.*


            where mysql-server-*.* should be replaced by the version that you have. (for me it'd be mysql-server-5.5). This will stop the database daemon. A prompt will then appear where you'd have to enter your new password and confirm the reconfiguration.



            snap1



            The daemon will be automatically started after the reconfig completes.




          3. You can then log in with:



            mysql -u root -p


            and start your database admin tasks.




          References:




          1. https://help.ubuntu.com/community/MysqlPasswordReset [Which would soon be cleaned up as indicated in the page.]


          2. Ubuntu Server Guide related to your specific version.







          share|improve this answer





















          • 2





            Can confirm that dpkg-reconfigure mariadb-server-10.1 worked for MariaDB when all other solutions didn't. Thank you for this.

            – liviucmg
            Oct 3 '14 at 21:49






          • 17





            dpkg-reconfigure didn't prompt for password for me.. is there a way to force it?

            – Unirgy
            Dec 17 '15 at 18:02






          • 15





            Did not work for me. I used the command as above, and got "Checking if update is needed. This installation of MySQL is already upgraded to 5.7.13, use --force if you still need to run mysql_upgrade". Using --force gave the same response.

            – Anthony Scaife
            Aug 14 '16 at 13:59








          • 5





            Apparently this does not work anymore.

            – dpi
            Jan 7 '17 at 18:05






          • 1





            @Paulo Henrique No. Given the situation, we decided the best use of our time was a full server reinstall.

            – Anthony Scaife
            Feb 23 '17 at 3:21



















          20














          Reference taken from this blog:



          Step 1:
          Stop MySQL Service.



          sudo service mysql stop


          Step 2:
          Kill all running mysqld.



          sudo killall -9 mysqld


          Step 3:
          Starting mysqld in Safe mode.



          sudo mysqld_safe --skip-grant-tables --skip-networking &


          Step 4:
          Start mysql client



          mysql -u root


          Step 5:
          After successful login, please execute this command to change any password.



          FLUSH PRIVILEGES;


          Step 6:
          You can update mysql root password .



          UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';


          for mysql > 5.7 use this instead of above:



          UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';


          Step 7:
          Please execute this command.



          FLUSH PRIVILEGES;


          Step 8:
          Exit mysql console



          exit


          Step 9:
          Kill mysqld_safe and start mysql



          sudo killall mysqld_safe && sudo service mysql start





          share|improve this answer





















          • 1





            should be sudo service mysql stop, not sudo stop mysql

            – knocte
            Jul 4 '16 at 3:51






          • 1





            also, at the end it's missing the steps sudo killall mysqld_safe && sudo service mysql start and then try to log in again

            – knocte
            Jul 4 '16 at 3:58






          • 3





            For MYSQL 5.7 the change password syntax has changed to ALTER USER root IDENTIFIED BY 'NEW_PASSWORD_HERE'

            – Tarek Fadel
            Jul 6 '16 at 7:55






          • 7





            NOTE! There is a new beast in MySQL 5.7 called auth_socket. If you install mysql without a root password, the beast will attack you and you'll loose 50 hitpoints. In step 6 above you need to ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEWPASS';. You can read about it here. Theoretically (I didn't try), you should be able to log in to mysql without a password if you "sudo su -" to become root.

            – olafure
            Oct 13 '16 at 13:14








          • 3





            And in case ALTER USER ... doesn't work, use UPDATE mysql.user SET authentication_string = PASSWORD('NEWPASS'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';

            – olafure
            Oct 13 '16 at 14:04



















          10














          Under Ubuntu 16.04 and mysql-server-5.7, the correct answer is the last comment of olafure, dpkg-reconfigure mysql-server-5.7 no longer works.



          sudo service mysql stop
          sudo killall mysqld
          sudo mysqld_safe --skip-grant-tables --skip-networking &
          mysql -u root


          Now in mysql console >mysql



          USE mysql;
          UPDATE user SET authentication_string=PASSWORD('newpass') WHERE user='root';
          FLUSH PRIVILEGES;
          q


          Restart the good mysql process



          sudo killall mysqld
          sudo service mysql start


          Check your new password



          mysql -u root -p
          Enter password: newpass
          mysql>





          share|improve this answer





















          • 4





            At mysqld_safe execution, I get the error: Directory '/var/run/mysqld' for UNIX socket file don't exists.. So I ran sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld and the rest of the above answer works. Is this a bug on Ubuntu 16? I've never experienced all these issues updating passwords before.

            – Chester
            Apr 2 '17 at 21:07











          • @Chester thank you very much!! This was the only way that finally worked now as all other solutions throw an error. (Ubuntu-Server 16.04 here) This should be added to the answer

            – derHugo
            May 30 '17 at 6:48



















          3














          Starting with MySQL 5.7, during initial installation, if you leave password empty, then for that user, authentication will be based on auth_socket plugin.



          The correct way to change password will be:



          ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';


          https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/






          share|improve this answer
























          • This was my exact case (empty password during installation in mysql 5.7) and this was the only solution for my case.

            – cherouvim
            Apr 19 '17 at 7:06











          • I get the message: ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

            – user2513149
            Aug 25 '18 at 5:31











          • @user2513149 Please restart your MySQL server without --skip-grant-tables option and see this solution works.

            – Barun
            Aug 25 '18 at 5:37











          • @Barun, no, without --skip-grant-tables option I can't even log into MySQL as root. It says ERROR 1698 (28000): Access denied for user 'root'@'localhost'

            – user2513149
            Aug 25 '18 at 5:58











          • Solved! I had to login to regular MySQL console (not mysqld_safe) as root without password. I have Ubuntu 18.04 and mysql-server-5.7. This answer helped me askubuntu.com/a/767252/585252 (see the bottom part)

            – user2513149
            Aug 25 '18 at 6:56





















          0














          Create a file with this:



          UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
          FLUSH PRIVILEGES;


          Stop the mysql server and run this:



          mysqld_safe --init-file=/home/me/mysql-init &


          Check here for more details:
          http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html






          share|improve this answer

































            0














            Nothing from the rest of the answers seemed to work for me. This is my solution:



            sudo service mysql stop
            sudo mysqld_safe &
            sudo mysql -u root


            In there:



            ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
            FLUSH PRIVILEGES;
            QUIT;


            Then:



            sudo killall mysqld
            sudo service mysql start
            sudo mysql -u root -p





            share|improve this answer
























            • The rest doesn't work for me neither ... nor does your solution unfortunately: Still get this Error 2017-05-30T06:33:22.291126Z mysqld_safe Logging to syslog. 2017-05-30T06:33:22.294375Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2017-05-30T06:33:22.296874Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

              – derHugo
              May 30 '17 at 6:34











            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f489098%2funable-to-reset-root-password-of-mysql%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            6 Answers
            6






            active

            oldest

            votes








            6 Answers
            6






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            43














            First please try using



            mysql -u root -p


            and enter your password (if you remember) at the prompt to login as the sql-root user (note the switch -p is for password).



            If you really have to reset your root password for mysql, here's an easy way - reconfigure the package with dpkg-reconfigure.



            Easy steps to reset mySQL root password:





            1. Check the version of your mysql-server;



              apt-cache policy mysql-server


              and see for the line which shows the installed version among other information. e.g. for my install it's:



              Installed: 5.5.37-0ubuntu0.12.04.1


              (From this I know that I have mysql-server-5.5 installed in my system.)




            2. Start the reconfiguration with:



              sudo dpkg-reconfigure mysql-server-*.*


              where mysql-server-*.* should be replaced by the version that you have. (for me it'd be mysql-server-5.5). This will stop the database daemon. A prompt will then appear where you'd have to enter your new password and confirm the reconfiguration.



              snap1



              The daemon will be automatically started after the reconfig completes.




            3. You can then log in with:



              mysql -u root -p


              and start your database admin tasks.




            References:




            1. https://help.ubuntu.com/community/MysqlPasswordReset [Which would soon be cleaned up as indicated in the page.]


            2. Ubuntu Server Guide related to your specific version.







            share|improve this answer





















            • 2





              Can confirm that dpkg-reconfigure mariadb-server-10.1 worked for MariaDB when all other solutions didn't. Thank you for this.

              – liviucmg
              Oct 3 '14 at 21:49






            • 17





              dpkg-reconfigure didn't prompt for password for me.. is there a way to force it?

              – Unirgy
              Dec 17 '15 at 18:02






            • 15





              Did not work for me. I used the command as above, and got "Checking if update is needed. This installation of MySQL is already upgraded to 5.7.13, use --force if you still need to run mysql_upgrade". Using --force gave the same response.

              – Anthony Scaife
              Aug 14 '16 at 13:59








            • 5





              Apparently this does not work anymore.

              – dpi
              Jan 7 '17 at 18:05






            • 1





              @Paulo Henrique No. Given the situation, we decided the best use of our time was a full server reinstall.

              – Anthony Scaife
              Feb 23 '17 at 3:21
















            43














            First please try using



            mysql -u root -p


            and enter your password (if you remember) at the prompt to login as the sql-root user (note the switch -p is for password).



            If you really have to reset your root password for mysql, here's an easy way - reconfigure the package with dpkg-reconfigure.



            Easy steps to reset mySQL root password:





            1. Check the version of your mysql-server;



              apt-cache policy mysql-server


              and see for the line which shows the installed version among other information. e.g. for my install it's:



              Installed: 5.5.37-0ubuntu0.12.04.1


              (From this I know that I have mysql-server-5.5 installed in my system.)




            2. Start the reconfiguration with:



              sudo dpkg-reconfigure mysql-server-*.*


              where mysql-server-*.* should be replaced by the version that you have. (for me it'd be mysql-server-5.5). This will stop the database daemon. A prompt will then appear where you'd have to enter your new password and confirm the reconfiguration.



              snap1



              The daemon will be automatically started after the reconfig completes.




            3. You can then log in with:



              mysql -u root -p


              and start your database admin tasks.




            References:




            1. https://help.ubuntu.com/community/MysqlPasswordReset [Which would soon be cleaned up as indicated in the page.]


            2. Ubuntu Server Guide related to your specific version.







            share|improve this answer





















            • 2





              Can confirm that dpkg-reconfigure mariadb-server-10.1 worked for MariaDB when all other solutions didn't. Thank you for this.

              – liviucmg
              Oct 3 '14 at 21:49






            • 17





              dpkg-reconfigure didn't prompt for password for me.. is there a way to force it?

              – Unirgy
              Dec 17 '15 at 18:02






            • 15





              Did not work for me. I used the command as above, and got "Checking if update is needed. This installation of MySQL is already upgraded to 5.7.13, use --force if you still need to run mysql_upgrade". Using --force gave the same response.

              – Anthony Scaife
              Aug 14 '16 at 13:59








            • 5





              Apparently this does not work anymore.

              – dpi
              Jan 7 '17 at 18:05






            • 1





              @Paulo Henrique No. Given the situation, we decided the best use of our time was a full server reinstall.

              – Anthony Scaife
              Feb 23 '17 at 3:21














            43












            43








            43







            First please try using



            mysql -u root -p


            and enter your password (if you remember) at the prompt to login as the sql-root user (note the switch -p is for password).



            If you really have to reset your root password for mysql, here's an easy way - reconfigure the package with dpkg-reconfigure.



            Easy steps to reset mySQL root password:





            1. Check the version of your mysql-server;



              apt-cache policy mysql-server


              and see for the line which shows the installed version among other information. e.g. for my install it's:



              Installed: 5.5.37-0ubuntu0.12.04.1


              (From this I know that I have mysql-server-5.5 installed in my system.)




            2. Start the reconfiguration with:



              sudo dpkg-reconfigure mysql-server-*.*


              where mysql-server-*.* should be replaced by the version that you have. (for me it'd be mysql-server-5.5). This will stop the database daemon. A prompt will then appear where you'd have to enter your new password and confirm the reconfiguration.



              snap1



              The daemon will be automatically started after the reconfig completes.




            3. You can then log in with:



              mysql -u root -p


              and start your database admin tasks.




            References:




            1. https://help.ubuntu.com/community/MysqlPasswordReset [Which would soon be cleaned up as indicated in the page.]


            2. Ubuntu Server Guide related to your specific version.







            share|improve this answer















            First please try using



            mysql -u root -p


            and enter your password (if you remember) at the prompt to login as the sql-root user (note the switch -p is for password).



            If you really have to reset your root password for mysql, here's an easy way - reconfigure the package with dpkg-reconfigure.



            Easy steps to reset mySQL root password:





            1. Check the version of your mysql-server;



              apt-cache policy mysql-server


              and see for the line which shows the installed version among other information. e.g. for my install it's:



              Installed: 5.5.37-0ubuntu0.12.04.1


              (From this I know that I have mysql-server-5.5 installed in my system.)




            2. Start the reconfiguration with:



              sudo dpkg-reconfigure mysql-server-*.*


              where mysql-server-*.* should be replaced by the version that you have. (for me it'd be mysql-server-5.5). This will stop the database daemon. A prompt will then appear where you'd have to enter your new password and confirm the reconfiguration.



              snap1



              The daemon will be automatically started after the reconfig completes.




            3. You can then log in with:



              mysql -u root -p


              and start your database admin tasks.




            References:




            1. https://help.ubuntu.com/community/MysqlPasswordReset [Which would soon be cleaned up as indicated in the page.]


            2. Ubuntu Server Guide related to your specific version.








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 18 '17 at 15:29









            muru

            1




            1










            answered Jun 28 '14 at 5:31









            preciseprecise

            10.7k65179




            10.7k65179








            • 2





              Can confirm that dpkg-reconfigure mariadb-server-10.1 worked for MariaDB when all other solutions didn't. Thank you for this.

              – liviucmg
              Oct 3 '14 at 21:49






            • 17





              dpkg-reconfigure didn't prompt for password for me.. is there a way to force it?

              – Unirgy
              Dec 17 '15 at 18:02






            • 15





              Did not work for me. I used the command as above, and got "Checking if update is needed. This installation of MySQL is already upgraded to 5.7.13, use --force if you still need to run mysql_upgrade". Using --force gave the same response.

              – Anthony Scaife
              Aug 14 '16 at 13:59








            • 5





              Apparently this does not work anymore.

              – dpi
              Jan 7 '17 at 18:05






            • 1





              @Paulo Henrique No. Given the situation, we decided the best use of our time was a full server reinstall.

              – Anthony Scaife
              Feb 23 '17 at 3:21














            • 2





              Can confirm that dpkg-reconfigure mariadb-server-10.1 worked for MariaDB when all other solutions didn't. Thank you for this.

              – liviucmg
              Oct 3 '14 at 21:49






            • 17





              dpkg-reconfigure didn't prompt for password for me.. is there a way to force it?

              – Unirgy
              Dec 17 '15 at 18:02






            • 15





              Did not work for me. I used the command as above, and got "Checking if update is needed. This installation of MySQL is already upgraded to 5.7.13, use --force if you still need to run mysql_upgrade". Using --force gave the same response.

              – Anthony Scaife
              Aug 14 '16 at 13:59








            • 5





              Apparently this does not work anymore.

              – dpi
              Jan 7 '17 at 18:05






            • 1





              @Paulo Henrique No. Given the situation, we decided the best use of our time was a full server reinstall.

              – Anthony Scaife
              Feb 23 '17 at 3:21








            2




            2





            Can confirm that dpkg-reconfigure mariadb-server-10.1 worked for MariaDB when all other solutions didn't. Thank you for this.

            – liviucmg
            Oct 3 '14 at 21:49





            Can confirm that dpkg-reconfigure mariadb-server-10.1 worked for MariaDB when all other solutions didn't. Thank you for this.

            – liviucmg
            Oct 3 '14 at 21:49




            17




            17





            dpkg-reconfigure didn't prompt for password for me.. is there a way to force it?

            – Unirgy
            Dec 17 '15 at 18:02





            dpkg-reconfigure didn't prompt for password for me.. is there a way to force it?

            – Unirgy
            Dec 17 '15 at 18:02




            15




            15





            Did not work for me. I used the command as above, and got "Checking if update is needed. This installation of MySQL is already upgraded to 5.7.13, use --force if you still need to run mysql_upgrade". Using --force gave the same response.

            – Anthony Scaife
            Aug 14 '16 at 13:59







            Did not work for me. I used the command as above, and got "Checking if update is needed. This installation of MySQL is already upgraded to 5.7.13, use --force if you still need to run mysql_upgrade". Using --force gave the same response.

            – Anthony Scaife
            Aug 14 '16 at 13:59






            5




            5





            Apparently this does not work anymore.

            – dpi
            Jan 7 '17 at 18:05





            Apparently this does not work anymore.

            – dpi
            Jan 7 '17 at 18:05




            1




            1





            @Paulo Henrique No. Given the situation, we decided the best use of our time was a full server reinstall.

            – Anthony Scaife
            Feb 23 '17 at 3:21





            @Paulo Henrique No. Given the situation, we decided the best use of our time was a full server reinstall.

            – Anthony Scaife
            Feb 23 '17 at 3:21













            20














            Reference taken from this blog:



            Step 1:
            Stop MySQL Service.



            sudo service mysql stop


            Step 2:
            Kill all running mysqld.



            sudo killall -9 mysqld


            Step 3:
            Starting mysqld in Safe mode.



            sudo mysqld_safe --skip-grant-tables --skip-networking &


            Step 4:
            Start mysql client



            mysql -u root


            Step 5:
            After successful login, please execute this command to change any password.



            FLUSH PRIVILEGES;


            Step 6:
            You can update mysql root password .



            UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';


            for mysql > 5.7 use this instead of above:



            UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';


            Step 7:
            Please execute this command.



            FLUSH PRIVILEGES;


            Step 8:
            Exit mysql console



            exit


            Step 9:
            Kill mysqld_safe and start mysql



            sudo killall mysqld_safe && sudo service mysql start





            share|improve this answer





















            • 1





              should be sudo service mysql stop, not sudo stop mysql

              – knocte
              Jul 4 '16 at 3:51






            • 1





              also, at the end it's missing the steps sudo killall mysqld_safe && sudo service mysql start and then try to log in again

              – knocte
              Jul 4 '16 at 3:58






            • 3





              For MYSQL 5.7 the change password syntax has changed to ALTER USER root IDENTIFIED BY 'NEW_PASSWORD_HERE'

              – Tarek Fadel
              Jul 6 '16 at 7:55






            • 7





              NOTE! There is a new beast in MySQL 5.7 called auth_socket. If you install mysql without a root password, the beast will attack you and you'll loose 50 hitpoints. In step 6 above you need to ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEWPASS';. You can read about it here. Theoretically (I didn't try), you should be able to log in to mysql without a password if you "sudo su -" to become root.

              – olafure
              Oct 13 '16 at 13:14








            • 3





              And in case ALTER USER ... doesn't work, use UPDATE mysql.user SET authentication_string = PASSWORD('NEWPASS'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';

              – olafure
              Oct 13 '16 at 14:04
















            20














            Reference taken from this blog:



            Step 1:
            Stop MySQL Service.



            sudo service mysql stop


            Step 2:
            Kill all running mysqld.



            sudo killall -9 mysqld


            Step 3:
            Starting mysqld in Safe mode.



            sudo mysqld_safe --skip-grant-tables --skip-networking &


            Step 4:
            Start mysql client



            mysql -u root


            Step 5:
            After successful login, please execute this command to change any password.



            FLUSH PRIVILEGES;


            Step 6:
            You can update mysql root password .



            UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';


            for mysql > 5.7 use this instead of above:



            UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';


            Step 7:
            Please execute this command.



            FLUSH PRIVILEGES;


            Step 8:
            Exit mysql console



            exit


            Step 9:
            Kill mysqld_safe and start mysql



            sudo killall mysqld_safe && sudo service mysql start





            share|improve this answer





















            • 1





              should be sudo service mysql stop, not sudo stop mysql

              – knocte
              Jul 4 '16 at 3:51






            • 1





              also, at the end it's missing the steps sudo killall mysqld_safe && sudo service mysql start and then try to log in again

              – knocte
              Jul 4 '16 at 3:58






            • 3





              For MYSQL 5.7 the change password syntax has changed to ALTER USER root IDENTIFIED BY 'NEW_PASSWORD_HERE'

              – Tarek Fadel
              Jul 6 '16 at 7:55






            • 7





              NOTE! There is a new beast in MySQL 5.7 called auth_socket. If you install mysql without a root password, the beast will attack you and you'll loose 50 hitpoints. In step 6 above you need to ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEWPASS';. You can read about it here. Theoretically (I didn't try), you should be able to log in to mysql without a password if you "sudo su -" to become root.

              – olafure
              Oct 13 '16 at 13:14








            • 3





              And in case ALTER USER ... doesn't work, use UPDATE mysql.user SET authentication_string = PASSWORD('NEWPASS'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';

              – olafure
              Oct 13 '16 at 14:04














            20












            20








            20







            Reference taken from this blog:



            Step 1:
            Stop MySQL Service.



            sudo service mysql stop


            Step 2:
            Kill all running mysqld.



            sudo killall -9 mysqld


            Step 3:
            Starting mysqld in Safe mode.



            sudo mysqld_safe --skip-grant-tables --skip-networking &


            Step 4:
            Start mysql client



            mysql -u root


            Step 5:
            After successful login, please execute this command to change any password.



            FLUSH PRIVILEGES;


            Step 6:
            You can update mysql root password .



            UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';


            for mysql > 5.7 use this instead of above:



            UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';


            Step 7:
            Please execute this command.



            FLUSH PRIVILEGES;


            Step 8:
            Exit mysql console



            exit


            Step 9:
            Kill mysqld_safe and start mysql



            sudo killall mysqld_safe && sudo service mysql start





            share|improve this answer















            Reference taken from this blog:



            Step 1:
            Stop MySQL Service.



            sudo service mysql stop


            Step 2:
            Kill all running mysqld.



            sudo killall -9 mysqld


            Step 3:
            Starting mysqld in Safe mode.



            sudo mysqld_safe --skip-grant-tables --skip-networking &


            Step 4:
            Start mysql client



            mysql -u root


            Step 5:
            After successful login, please execute this command to change any password.



            FLUSH PRIVILEGES;


            Step 6:
            You can update mysql root password .



            UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';


            for mysql > 5.7 use this instead of above:



            UPDATE mysql.user SET authentication_string=PASSWORD('newpwd') WHERE User='root';


            Step 7:
            Please execute this command.



            FLUSH PRIVILEGES;


            Step 8:
            Exit mysql console



            exit


            Step 9:
            Kill mysqld_safe and start mysql



            sudo killall mysqld_safe && sudo service mysql start






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 24 '16 at 12:54









            Mehraban

            6402921




            6402921










            answered Sep 8 '15 at 5:33









            AnveshAnvesh

            50154




            50154








            • 1





              should be sudo service mysql stop, not sudo stop mysql

              – knocte
              Jul 4 '16 at 3:51






            • 1





              also, at the end it's missing the steps sudo killall mysqld_safe && sudo service mysql start and then try to log in again

              – knocte
              Jul 4 '16 at 3:58






            • 3





              For MYSQL 5.7 the change password syntax has changed to ALTER USER root IDENTIFIED BY 'NEW_PASSWORD_HERE'

              – Tarek Fadel
              Jul 6 '16 at 7:55






            • 7





              NOTE! There is a new beast in MySQL 5.7 called auth_socket. If you install mysql without a root password, the beast will attack you and you'll loose 50 hitpoints. In step 6 above you need to ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEWPASS';. You can read about it here. Theoretically (I didn't try), you should be able to log in to mysql without a password if you "sudo su -" to become root.

              – olafure
              Oct 13 '16 at 13:14








            • 3





              And in case ALTER USER ... doesn't work, use UPDATE mysql.user SET authentication_string = PASSWORD('NEWPASS'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';

              – olafure
              Oct 13 '16 at 14:04














            • 1





              should be sudo service mysql stop, not sudo stop mysql

              – knocte
              Jul 4 '16 at 3:51






            • 1





              also, at the end it's missing the steps sudo killall mysqld_safe && sudo service mysql start and then try to log in again

              – knocte
              Jul 4 '16 at 3:58






            • 3





              For MYSQL 5.7 the change password syntax has changed to ALTER USER root IDENTIFIED BY 'NEW_PASSWORD_HERE'

              – Tarek Fadel
              Jul 6 '16 at 7:55






            • 7





              NOTE! There is a new beast in MySQL 5.7 called auth_socket. If you install mysql without a root password, the beast will attack you and you'll loose 50 hitpoints. In step 6 above you need to ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEWPASS';. You can read about it here. Theoretically (I didn't try), you should be able to log in to mysql without a password if you "sudo su -" to become root.

              – olafure
              Oct 13 '16 at 13:14








            • 3





              And in case ALTER USER ... doesn't work, use UPDATE mysql.user SET authentication_string = PASSWORD('NEWPASS'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';

              – olafure
              Oct 13 '16 at 14:04








            1




            1





            should be sudo service mysql stop, not sudo stop mysql

            – knocte
            Jul 4 '16 at 3:51





            should be sudo service mysql stop, not sudo stop mysql

            – knocte
            Jul 4 '16 at 3:51




            1




            1





            also, at the end it's missing the steps sudo killall mysqld_safe && sudo service mysql start and then try to log in again

            – knocte
            Jul 4 '16 at 3:58





            also, at the end it's missing the steps sudo killall mysqld_safe && sudo service mysql start and then try to log in again

            – knocte
            Jul 4 '16 at 3:58




            3




            3





            For MYSQL 5.7 the change password syntax has changed to ALTER USER root IDENTIFIED BY 'NEW_PASSWORD_HERE'

            – Tarek Fadel
            Jul 6 '16 at 7:55





            For MYSQL 5.7 the change password syntax has changed to ALTER USER root IDENTIFIED BY 'NEW_PASSWORD_HERE'

            – Tarek Fadel
            Jul 6 '16 at 7:55




            7




            7





            NOTE! There is a new beast in MySQL 5.7 called auth_socket. If you install mysql without a root password, the beast will attack you and you'll loose 50 hitpoints. In step 6 above you need to ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEWPASS';. You can read about it here. Theoretically (I didn't try), you should be able to log in to mysql without a password if you "sudo su -" to become root.

            – olafure
            Oct 13 '16 at 13:14







            NOTE! There is a new beast in MySQL 5.7 called auth_socket. If you install mysql without a root password, the beast will attack you and you'll loose 50 hitpoints. In step 6 above you need to ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NEWPASS';. You can read about it here. Theoretically (I didn't try), you should be able to log in to mysql without a password if you "sudo su -" to become root.

            – olafure
            Oct 13 '16 at 13:14






            3




            3





            And in case ALTER USER ... doesn't work, use UPDATE mysql.user SET authentication_string = PASSWORD('NEWPASS'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';

            – olafure
            Oct 13 '16 at 14:04





            And in case ALTER USER ... doesn't work, use UPDATE mysql.user SET authentication_string = PASSWORD('NEWPASS'), plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost';

            – olafure
            Oct 13 '16 at 14:04











            10














            Under Ubuntu 16.04 and mysql-server-5.7, the correct answer is the last comment of olafure, dpkg-reconfigure mysql-server-5.7 no longer works.



            sudo service mysql stop
            sudo killall mysqld
            sudo mysqld_safe --skip-grant-tables --skip-networking &
            mysql -u root


            Now in mysql console >mysql



            USE mysql;
            UPDATE user SET authentication_string=PASSWORD('newpass') WHERE user='root';
            FLUSH PRIVILEGES;
            q


            Restart the good mysql process



            sudo killall mysqld
            sudo service mysql start


            Check your new password



            mysql -u root -p
            Enter password: newpass
            mysql>





            share|improve this answer





















            • 4





              At mysqld_safe execution, I get the error: Directory '/var/run/mysqld' for UNIX socket file don't exists.. So I ran sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld and the rest of the above answer works. Is this a bug on Ubuntu 16? I've never experienced all these issues updating passwords before.

              – Chester
              Apr 2 '17 at 21:07











            • @Chester thank you very much!! This was the only way that finally worked now as all other solutions throw an error. (Ubuntu-Server 16.04 here) This should be added to the answer

              – derHugo
              May 30 '17 at 6:48
















            10














            Under Ubuntu 16.04 and mysql-server-5.7, the correct answer is the last comment of olafure, dpkg-reconfigure mysql-server-5.7 no longer works.



            sudo service mysql stop
            sudo killall mysqld
            sudo mysqld_safe --skip-grant-tables --skip-networking &
            mysql -u root


            Now in mysql console >mysql



            USE mysql;
            UPDATE user SET authentication_string=PASSWORD('newpass') WHERE user='root';
            FLUSH PRIVILEGES;
            q


            Restart the good mysql process



            sudo killall mysqld
            sudo service mysql start


            Check your new password



            mysql -u root -p
            Enter password: newpass
            mysql>





            share|improve this answer





















            • 4





              At mysqld_safe execution, I get the error: Directory '/var/run/mysqld' for UNIX socket file don't exists.. So I ran sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld and the rest of the above answer works. Is this a bug on Ubuntu 16? I've never experienced all these issues updating passwords before.

              – Chester
              Apr 2 '17 at 21:07











            • @Chester thank you very much!! This was the only way that finally worked now as all other solutions throw an error. (Ubuntu-Server 16.04 here) This should be added to the answer

              – derHugo
              May 30 '17 at 6:48














            10












            10








            10







            Under Ubuntu 16.04 and mysql-server-5.7, the correct answer is the last comment of olafure, dpkg-reconfigure mysql-server-5.7 no longer works.



            sudo service mysql stop
            sudo killall mysqld
            sudo mysqld_safe --skip-grant-tables --skip-networking &
            mysql -u root


            Now in mysql console >mysql



            USE mysql;
            UPDATE user SET authentication_string=PASSWORD('newpass') WHERE user='root';
            FLUSH PRIVILEGES;
            q


            Restart the good mysql process



            sudo killall mysqld
            sudo service mysql start


            Check your new password



            mysql -u root -p
            Enter password: newpass
            mysql>





            share|improve this answer















            Under Ubuntu 16.04 and mysql-server-5.7, the correct answer is the last comment of olafure, dpkg-reconfigure mysql-server-5.7 no longer works.



            sudo service mysql stop
            sudo killall mysqld
            sudo mysqld_safe --skip-grant-tables --skip-networking &
            mysql -u root


            Now in mysql console >mysql



            USE mysql;
            UPDATE user SET authentication_string=PASSWORD('newpass') WHERE user='root';
            FLUSH PRIVILEGES;
            q


            Restart the good mysql process



            sudo killall mysqld
            sudo service mysql start


            Check your new password



            mysql -u root -p
            Enter password: newpass
            mysql>






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Aug 2 '17 at 21:37









            Evan Carroll

            4,837113567




            4,837113567










            answered Nov 22 '16 at 11:05









            Pierre-DamienPierre-Damien

            14019




            14019








            • 4





              At mysqld_safe execution, I get the error: Directory '/var/run/mysqld' for UNIX socket file don't exists.. So I ran sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld and the rest of the above answer works. Is this a bug on Ubuntu 16? I've never experienced all these issues updating passwords before.

              – Chester
              Apr 2 '17 at 21:07











            • @Chester thank you very much!! This was the only way that finally worked now as all other solutions throw an error. (Ubuntu-Server 16.04 here) This should be added to the answer

              – derHugo
              May 30 '17 at 6:48














            • 4





              At mysqld_safe execution, I get the error: Directory '/var/run/mysqld' for UNIX socket file don't exists.. So I ran sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld and the rest of the above answer works. Is this a bug on Ubuntu 16? I've never experienced all these issues updating passwords before.

              – Chester
              Apr 2 '17 at 21:07











            • @Chester thank you very much!! This was the only way that finally worked now as all other solutions throw an error. (Ubuntu-Server 16.04 here) This should be added to the answer

              – derHugo
              May 30 '17 at 6:48








            4




            4





            At mysqld_safe execution, I get the error: Directory '/var/run/mysqld' for UNIX socket file don't exists.. So I ran sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld and the rest of the above answer works. Is this a bug on Ubuntu 16? I've never experienced all these issues updating passwords before.

            – Chester
            Apr 2 '17 at 21:07





            At mysqld_safe execution, I get the error: Directory '/var/run/mysqld' for UNIX socket file don't exists.. So I ran sudo mkdir /var/run/mysqld; sudo chown mysql /var/run/mysqld and the rest of the above answer works. Is this a bug on Ubuntu 16? I've never experienced all these issues updating passwords before.

            – Chester
            Apr 2 '17 at 21:07













            @Chester thank you very much!! This was the only way that finally worked now as all other solutions throw an error. (Ubuntu-Server 16.04 here) This should be added to the answer

            – derHugo
            May 30 '17 at 6:48





            @Chester thank you very much!! This was the only way that finally worked now as all other solutions throw an error. (Ubuntu-Server 16.04 here) This should be added to the answer

            – derHugo
            May 30 '17 at 6:48











            3














            Starting with MySQL 5.7, during initial installation, if you leave password empty, then for that user, authentication will be based on auth_socket plugin.



            The correct way to change password will be:



            ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';


            https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/






            share|improve this answer
























            • This was my exact case (empty password during installation in mysql 5.7) and this was the only solution for my case.

              – cherouvim
              Apr 19 '17 at 7:06











            • I get the message: ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

              – user2513149
              Aug 25 '18 at 5:31











            • @user2513149 Please restart your MySQL server without --skip-grant-tables option and see this solution works.

              – Barun
              Aug 25 '18 at 5:37











            • @Barun, no, without --skip-grant-tables option I can't even log into MySQL as root. It says ERROR 1698 (28000): Access denied for user 'root'@'localhost'

              – user2513149
              Aug 25 '18 at 5:58











            • Solved! I had to login to regular MySQL console (not mysqld_safe) as root without password. I have Ubuntu 18.04 and mysql-server-5.7. This answer helped me askubuntu.com/a/767252/585252 (see the bottom part)

              – user2513149
              Aug 25 '18 at 6:56


















            3














            Starting with MySQL 5.7, during initial installation, if you leave password empty, then for that user, authentication will be based on auth_socket plugin.



            The correct way to change password will be:



            ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';


            https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/






            share|improve this answer
























            • This was my exact case (empty password during installation in mysql 5.7) and this was the only solution for my case.

              – cherouvim
              Apr 19 '17 at 7:06











            • I get the message: ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

              – user2513149
              Aug 25 '18 at 5:31











            • @user2513149 Please restart your MySQL server without --skip-grant-tables option and see this solution works.

              – Barun
              Aug 25 '18 at 5:37











            • @Barun, no, without --skip-grant-tables option I can't even log into MySQL as root. It says ERROR 1698 (28000): Access denied for user 'root'@'localhost'

              – user2513149
              Aug 25 '18 at 5:58











            • Solved! I had to login to regular MySQL console (not mysqld_safe) as root without password. I have Ubuntu 18.04 and mysql-server-5.7. This answer helped me askubuntu.com/a/767252/585252 (see the bottom part)

              – user2513149
              Aug 25 '18 at 6:56
















            3












            3








            3







            Starting with MySQL 5.7, during initial installation, if you leave password empty, then for that user, authentication will be based on auth_socket plugin.



            The correct way to change password will be:



            ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';


            https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/






            share|improve this answer













            Starting with MySQL 5.7, during initial installation, if you leave password empty, then for that user, authentication will be based on auth_socket plugin.



            The correct way to change password will be:



            ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';


            https://www.percona.com/blog/2016/03/16/change-user-password-in-mysql-5-7-with-plugin-auth_socket/







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 20 '17 at 19:41









            BarunBarun

            335139




            335139













            • This was my exact case (empty password during installation in mysql 5.7) and this was the only solution for my case.

              – cherouvim
              Apr 19 '17 at 7:06











            • I get the message: ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

              – user2513149
              Aug 25 '18 at 5:31











            • @user2513149 Please restart your MySQL server without --skip-grant-tables option and see this solution works.

              – Barun
              Aug 25 '18 at 5:37











            • @Barun, no, without --skip-grant-tables option I can't even log into MySQL as root. It says ERROR 1698 (28000): Access denied for user 'root'@'localhost'

              – user2513149
              Aug 25 '18 at 5:58











            • Solved! I had to login to regular MySQL console (not mysqld_safe) as root without password. I have Ubuntu 18.04 and mysql-server-5.7. This answer helped me askubuntu.com/a/767252/585252 (see the bottom part)

              – user2513149
              Aug 25 '18 at 6:56





















            • This was my exact case (empty password during installation in mysql 5.7) and this was the only solution for my case.

              – cherouvim
              Apr 19 '17 at 7:06











            • I get the message: ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

              – user2513149
              Aug 25 '18 at 5:31











            • @user2513149 Please restart your MySQL server without --skip-grant-tables option and see this solution works.

              – Barun
              Aug 25 '18 at 5:37











            • @Barun, no, without --skip-grant-tables option I can't even log into MySQL as root. It says ERROR 1698 (28000): Access denied for user 'root'@'localhost'

              – user2513149
              Aug 25 '18 at 5:58











            • Solved! I had to login to regular MySQL console (not mysqld_safe) as root without password. I have Ubuntu 18.04 and mysql-server-5.7. This answer helped me askubuntu.com/a/767252/585252 (see the bottom part)

              – user2513149
              Aug 25 '18 at 6:56



















            This was my exact case (empty password during installation in mysql 5.7) and this was the only solution for my case.

            – cherouvim
            Apr 19 '17 at 7:06





            This was my exact case (empty password during installation in mysql 5.7) and this was the only solution for my case.

            – cherouvim
            Apr 19 '17 at 7:06













            I get the message: ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

            – user2513149
            Aug 25 '18 at 5:31





            I get the message: ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

            – user2513149
            Aug 25 '18 at 5:31













            @user2513149 Please restart your MySQL server without --skip-grant-tables option and see this solution works.

            – Barun
            Aug 25 '18 at 5:37





            @user2513149 Please restart your MySQL server without --skip-grant-tables option and see this solution works.

            – Barun
            Aug 25 '18 at 5:37













            @Barun, no, without --skip-grant-tables option I can't even log into MySQL as root. It says ERROR 1698 (28000): Access denied for user 'root'@'localhost'

            – user2513149
            Aug 25 '18 at 5:58





            @Barun, no, without --skip-grant-tables option I can't even log into MySQL as root. It says ERROR 1698 (28000): Access denied for user 'root'@'localhost'

            – user2513149
            Aug 25 '18 at 5:58













            Solved! I had to login to regular MySQL console (not mysqld_safe) as root without password. I have Ubuntu 18.04 and mysql-server-5.7. This answer helped me askubuntu.com/a/767252/585252 (see the bottom part)

            – user2513149
            Aug 25 '18 at 6:56







            Solved! I had to login to regular MySQL console (not mysqld_safe) as root without password. I have Ubuntu 18.04 and mysql-server-5.7. This answer helped me askubuntu.com/a/767252/585252 (see the bottom part)

            – user2513149
            Aug 25 '18 at 6:56













            0














            Create a file with this:



            UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
            FLUSH PRIVILEGES;


            Stop the mysql server and run this:



            mysqld_safe --init-file=/home/me/mysql-init &


            Check here for more details:
            http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html






            share|improve this answer






























              0














              Create a file with this:



              UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
              FLUSH PRIVILEGES;


              Stop the mysql server and run this:



              mysqld_safe --init-file=/home/me/mysql-init &


              Check here for more details:
              http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html






              share|improve this answer




























                0












                0








                0







                Create a file with this:



                UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
                FLUSH PRIVILEGES;


                Stop the mysql server and run this:



                mysqld_safe --init-file=/home/me/mysql-init &


                Check here for more details:
                http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html






                share|improve this answer















                Create a file with this:



                UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
                FLUSH PRIVILEGES;


                Stop the mysql server and run this:



                mysqld_safe --init-file=/home/me/mysql-init &


                Check here for more details:
                http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 10 '14 at 5:22









                user.dz

                35k1196178




                35k1196178










                answered Dec 10 '14 at 2:47









                ElierElier

                11




                11























                    0














                    Nothing from the rest of the answers seemed to work for me. This is my solution:



                    sudo service mysql stop
                    sudo mysqld_safe &
                    sudo mysql -u root


                    In there:



                    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
                    FLUSH PRIVILEGES;
                    QUIT;


                    Then:



                    sudo killall mysqld
                    sudo service mysql start
                    sudo mysql -u root -p





                    share|improve this answer
























                    • The rest doesn't work for me neither ... nor does your solution unfortunately: Still get this Error 2017-05-30T06:33:22.291126Z mysqld_safe Logging to syslog. 2017-05-30T06:33:22.294375Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2017-05-30T06:33:22.296874Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

                      – derHugo
                      May 30 '17 at 6:34
















                    0














                    Nothing from the rest of the answers seemed to work for me. This is my solution:



                    sudo service mysql stop
                    sudo mysqld_safe &
                    sudo mysql -u root


                    In there:



                    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
                    FLUSH PRIVILEGES;
                    QUIT;


                    Then:



                    sudo killall mysqld
                    sudo service mysql start
                    sudo mysql -u root -p





                    share|improve this answer
























                    • The rest doesn't work for me neither ... nor does your solution unfortunately: Still get this Error 2017-05-30T06:33:22.291126Z mysqld_safe Logging to syslog. 2017-05-30T06:33:22.294375Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2017-05-30T06:33:22.296874Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

                      – derHugo
                      May 30 '17 at 6:34














                    0












                    0








                    0







                    Nothing from the rest of the answers seemed to work for me. This is my solution:



                    sudo service mysql stop
                    sudo mysqld_safe &
                    sudo mysql -u root


                    In there:



                    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
                    FLUSH PRIVILEGES;
                    QUIT;


                    Then:



                    sudo killall mysqld
                    sudo service mysql start
                    sudo mysql -u root -p





                    share|improve this answer













                    Nothing from the rest of the answers seemed to work for me. This is my solution:



                    sudo service mysql stop
                    sudo mysqld_safe &
                    sudo mysql -u root


                    In there:



                    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
                    FLUSH PRIVILEGES;
                    QUIT;


                    Then:



                    sudo killall mysqld
                    sudo service mysql start
                    sudo mysql -u root -p






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 19 '17 at 21:40









                    WtowerWtower

                    389613




                    389613













                    • The rest doesn't work for me neither ... nor does your solution unfortunately: Still get this Error 2017-05-30T06:33:22.291126Z mysqld_safe Logging to syslog. 2017-05-30T06:33:22.294375Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2017-05-30T06:33:22.296874Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

                      – derHugo
                      May 30 '17 at 6:34



















                    • The rest doesn't work for me neither ... nor does your solution unfortunately: Still get this Error 2017-05-30T06:33:22.291126Z mysqld_safe Logging to syslog. 2017-05-30T06:33:22.294375Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2017-05-30T06:33:22.296874Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

                      – derHugo
                      May 30 '17 at 6:34

















                    The rest doesn't work for me neither ... nor does your solution unfortunately: Still get this Error 2017-05-30T06:33:22.291126Z mysqld_safe Logging to syslog. 2017-05-30T06:33:22.294375Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2017-05-30T06:33:22.296874Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

                    – derHugo
                    May 30 '17 at 6:34





                    The rest doesn't work for me neither ... nor does your solution unfortunately: Still get this Error 2017-05-30T06:33:22.291126Z mysqld_safe Logging to syslog. 2017-05-30T06:33:22.294375Z mysqld_safe Logging to '/var/log/mysql/error.log'. 2017-05-30T06:33:22.296874Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

                    – derHugo
                    May 30 '17 at 6:34


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f489098%2funable-to-reset-root-password-of-mysql%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to make a Squid Proxy server?

                    Is this a new Fibonacci Identity?

                    19世紀