how to login mysql shell when mysql have no password





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I got this error:



root@sys3026:/home/sys3026# mysql --user=root --password    
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


Any one please help me.
Thanks in advance..










share|improve this question































    0















    I got this error:



    root@sys3026:/home/sys3026# mysql --user=root --password    
    Enter password:
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


    Any one please help me.
    Thanks in advance..










    share|improve this question



























      0












      0








      0








      I got this error:



      root@sys3026:/home/sys3026# mysql --user=root --password    
      Enter password:
      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


      Any one please help me.
      Thanks in advance..










      share|improve this question
















      I got this error:



      root@sys3026:/home/sys3026# mysql --user=root --password    
      Enter password:
      ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


      Any one please help me.
      Thanks in advance..







      permissions login mysql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 16 '17 at 5:14









      muru

      1




      1










      asked May 16 '17 at 4:49









      veerakrishna pachhipalaveerakrishna pachhipala

      112




      112






















          4 Answers
          4






          active

          oldest

          votes


















          0














          Try this.



          This is the command to run mysql when no password is set, But If you just installed it and you did not set any password, I am pretty sure it still has a random password that can be found in logs located in /var/log/mysql.



          mysql -u root






          share|improve this answer































            0














            If your database has no password, just leave out the --password parameter.



            $ mysql --user=root


            Reference:




            • https://stackoverflow.com/questions/3843973/mysql-is-prompting-for-password-even-though-my-password-is-empty






            share|improve this answer

































              0














              If you have forgotten your password or you can not login you can always run mysql in a "safe_mode". Which allows you to access it without any password restriction - to change the root password or adjust something else if something went wrong.



              systemctl stop mysql
              sudo mysqld_safe --skip-grant-tables &


              Now you can access the mysql server without a password.



              mysql -uroot


              Add a new password to the root user in the mysql shell



              use mysql;
              update user set password=PASSWORD("newpassword") where User='root';
              flush privileges;


              Now restart it in normal mode again and it will work with the new password.



              systemctl stop mysql
              systemctl start mysql





              share|improve this answer

































                0














                When a MySQL user is configured to use auth_socket (instead of mysql_native_password), as it is by default in Ubuntu 18.04, you can log-in as root (for example) in the following way:



                sudo mysql -u'root'


                or just:



                sudo mysql


                References:




                • Digital Ocean: How To Install MySQL on Ubuntu 18.04 - read Step 3






                share|improve this answer
























                  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%2f915585%2fhow-to-login-mysql-shell-when-mysql-have-no-password%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  0














                  Try this.



                  This is the command to run mysql when no password is set, But If you just installed it and you did not set any password, I am pretty sure it still has a random password that can be found in logs located in /var/log/mysql.



                  mysql -u root






                  share|improve this answer




























                    0














                    Try this.



                    This is the command to run mysql when no password is set, But If you just installed it and you did not set any password, I am pretty sure it still has a random password that can be found in logs located in /var/log/mysql.



                    mysql -u root






                    share|improve this answer


























                      0












                      0








                      0







                      Try this.



                      This is the command to run mysql when no password is set, But If you just installed it and you did not set any password, I am pretty sure it still has a random password that can be found in logs located in /var/log/mysql.



                      mysql -u root






                      share|improve this answer













                      Try this.



                      This is the command to run mysql when no password is set, But If you just installed it and you did not set any password, I am pretty sure it still has a random password that can be found in logs located in /var/log/mysql.



                      mysql -u root







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered May 16 '17 at 5:49









                      Ishan JainIshan Jain

                      1212




                      1212

























                          0














                          If your database has no password, just leave out the --password parameter.



                          $ mysql --user=root


                          Reference:




                          • https://stackoverflow.com/questions/3843973/mysql-is-prompting-for-password-even-though-my-password-is-empty






                          share|improve this answer






























                            0














                            If your database has no password, just leave out the --password parameter.



                            $ mysql --user=root


                            Reference:




                            • https://stackoverflow.com/questions/3843973/mysql-is-prompting-for-password-even-though-my-password-is-empty






                            share|improve this answer




























                              0












                              0








                              0







                              If your database has no password, just leave out the --password parameter.



                              $ mysql --user=root


                              Reference:




                              • https://stackoverflow.com/questions/3843973/mysql-is-prompting-for-password-even-though-my-password-is-empty






                              share|improve this answer















                              If your database has no password, just leave out the --password parameter.



                              $ mysql --user=root


                              Reference:




                              • https://stackoverflow.com/questions/3843973/mysql-is-prompting-for-password-even-though-my-password-is-empty







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited May 23 '17 at 12:39









                              Community

                              1




                              1










                              answered May 16 '17 at 11:12









                              MelebiusMelebius

                              5,09352041




                              5,09352041























                                  0














                                  If you have forgotten your password or you can not login you can always run mysql in a "safe_mode". Which allows you to access it without any password restriction - to change the root password or adjust something else if something went wrong.



                                  systemctl stop mysql
                                  sudo mysqld_safe --skip-grant-tables &


                                  Now you can access the mysql server without a password.



                                  mysql -uroot


                                  Add a new password to the root user in the mysql shell



                                  use mysql;
                                  update user set password=PASSWORD("newpassword") where User='root';
                                  flush privileges;


                                  Now restart it in normal mode again and it will work with the new password.



                                  systemctl stop mysql
                                  systemctl start mysql





                                  share|improve this answer






























                                    0














                                    If you have forgotten your password or you can not login you can always run mysql in a "safe_mode". Which allows you to access it without any password restriction - to change the root password or adjust something else if something went wrong.



                                    systemctl stop mysql
                                    sudo mysqld_safe --skip-grant-tables &


                                    Now you can access the mysql server without a password.



                                    mysql -uroot


                                    Add a new password to the root user in the mysql shell



                                    use mysql;
                                    update user set password=PASSWORD("newpassword") where User='root';
                                    flush privileges;


                                    Now restart it in normal mode again and it will work with the new password.



                                    systemctl stop mysql
                                    systemctl start mysql





                                    share|improve this answer




























                                      0












                                      0








                                      0







                                      If you have forgotten your password or you can not login you can always run mysql in a "safe_mode". Which allows you to access it without any password restriction - to change the root password or adjust something else if something went wrong.



                                      systemctl stop mysql
                                      sudo mysqld_safe --skip-grant-tables &


                                      Now you can access the mysql server without a password.



                                      mysql -uroot


                                      Add a new password to the root user in the mysql shell



                                      use mysql;
                                      update user set password=PASSWORD("newpassword") where User='root';
                                      flush privileges;


                                      Now restart it in normal mode again and it will work with the new password.



                                      systemctl stop mysql
                                      systemctl start mysql





                                      share|improve this answer















                                      If you have forgotten your password or you can not login you can always run mysql in a "safe_mode". Which allows you to access it without any password restriction - to change the root password or adjust something else if something went wrong.



                                      systemctl stop mysql
                                      sudo mysqld_safe --skip-grant-tables &


                                      Now you can access the mysql server without a password.



                                      mysql -uroot


                                      Add a new password to the root user in the mysql shell



                                      use mysql;
                                      update user set password=PASSWORD("newpassword") where User='root';
                                      flush privileges;


                                      Now restart it in normal mode again and it will work with the new password.



                                      systemctl stop mysql
                                      systemctl start mysql






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited May 22 '18 at 3:40









                                      fosslinux

                                      2,39521837




                                      2,39521837










                                      answered May 16 '17 at 10:41









                                      ZiazisZiazis

                                      1,913419




                                      1,913419























                                          0














                                          When a MySQL user is configured to use auth_socket (instead of mysql_native_password), as it is by default in Ubuntu 18.04, you can log-in as root (for example) in the following way:



                                          sudo mysql -u'root'


                                          or just:



                                          sudo mysql


                                          References:




                                          • Digital Ocean: How To Install MySQL on Ubuntu 18.04 - read Step 3






                                          share|improve this answer




























                                            0














                                            When a MySQL user is configured to use auth_socket (instead of mysql_native_password), as it is by default in Ubuntu 18.04, you can log-in as root (for example) in the following way:



                                            sudo mysql -u'root'


                                            or just:



                                            sudo mysql


                                            References:




                                            • Digital Ocean: How To Install MySQL on Ubuntu 18.04 - read Step 3






                                            share|improve this answer


























                                              0












                                              0








                                              0







                                              When a MySQL user is configured to use auth_socket (instead of mysql_native_password), as it is by default in Ubuntu 18.04, you can log-in as root (for example) in the following way:



                                              sudo mysql -u'root'


                                              or just:



                                              sudo mysql


                                              References:




                                              • Digital Ocean: How To Install MySQL on Ubuntu 18.04 - read Step 3






                                              share|improve this answer













                                              When a MySQL user is configured to use auth_socket (instead of mysql_native_password), as it is by default in Ubuntu 18.04, you can log-in as root (for example) in the following way:



                                              sudo mysql -u'root'


                                              or just:



                                              sudo mysql


                                              References:




                                              • Digital Ocean: How To Install MySQL on Ubuntu 18.04 - read Step 3







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Mar 28 at 19:45









                                              pa4080pa4080

                                              14.8k52873




                                              14.8k52873






























                                                  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%2f915585%2fhow-to-login-mysql-shell-when-mysql-have-no-password%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 did Captain America manage to do this?

                                                  迪纳利

                                                  南乌拉尔铁路局