MySQL Forgot login password

Source: Internet
Author: User

    1. MySQL (mariadb) forgot login password, prompt as follows

[Email protected] ~]# mysql-uroot-penter password:error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)


2. Stop MySQL

[Email protected] ~]# Systemctl stop mariadb


3. Use--skip-grant-tables to connect MySQL, at this time MySQL cannot authorize operation, can reset password

[Email protected] ~]# mysqld_safe--skip-grant-tables 161103 14:52:25 mysqld_safe Logging to '/var/log/mariadb/ Mariadb.log '. 161103 14:52:25 mysqld_safe A mysqld process already exists


4. Turn on MySQL and go directly to

[[email protected] ~]# systemctl start mariadb[[email protected] ~]#  Mysqlwelcome to the mariadb monitor.  commands end with ; or  \g.your mariadb connection id is 2server version: 5.5.50-mariadb  MariaDB ServerCopyright  (c)  2000, 2016, oracle, mariadb corporation  ab and others. type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement. mariadb [(None)]> use mysql; reading table information for completion of table and column  Namesyou can turn off this feature to get a quicker startup  with -adatabase changedmariadb [mysql]> update user set password= Password (' 123456 ')  where user= ' root '; query ok, 4 rows affected  (0.00 sec) rows matched: 4  changed : 4  warnings: 0mariadb [mysql]> flush privileges     -> ; query ok, 0 rows affected  (0.00 sec) mariadb [mysql]> exit; Bye


5. Reset Password to 123456, test login

[Email protected] ~]# Mysql-uroot-penter password:welcome to the MariaDB Monitor. Commands End With; or \g.your MariaDB connection ID is 3Server version:5.5.50-mariadb MariaDB servercopyright (c), Oracle, Mariad B Corporation Ab and others. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. MariaDB [(None)]>


This article is from the "Linux Sailing" blog, make sure to keep this source http://jiayimeng.blog.51cto.com/10604001/1868955

MySQL Forgot login password

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.