MySQL Database login password management

Source: Internet
Author: User
Tags mysql command line

MySQL Database installation Complete the default administrator's login password is empty, so you can not enter the password to log in directly to the database, which is not secure, the following article briefly describes how to set the Administrator login database password and how to modify the login password, and forget how to handle the login password.

I. Introduction to the Environment

Operating system: CentOS 6.5

Database version: MySQL 5.5.32

Host Name: Mysql-singleton

Second, the Database password management

1. Set the database initial password

[Email protected] ~]# mysqladmin-uoldcat password "123456"

2, the command line to modify the database login password

1) Linux command line modify MySQL database password

[Email protected] ~]# mysqladmin-uoldcat-p123456 password "oldcat123"

2) MySQL command line change password

mysql> select user,host,password from mysql.user;+--------+------+--------------------- ----------------------+| user  | host| password                    |+--------+------+-------------- -----------------------------+| oldcat| %   |* 41a67287d4bd4e7159dd624068d666adc8917813 |+--------+------+-------------------------------------------+1  row in set  (0.00 sec) mysql> update mysql.user set password= Password ("123456")  where user= "Oldcat"; query ok, 1 row affected  (0.00 sec) rows matched: 1  changed:  1  WARNINGS: 0 Note: Password plaintext is encrypted with the password function mysql> flush privileges; query ok, 0 rows affected  (0.00 SEC) Note: Modify password execution flush privileges Refresh cache, Make it immediately invalid or you can modify the password of the currently logged on user directly through the SET command MysQl> set password=password ("oldcat123"); query ok, 0 rows affected  (0.00 SEC)

 3) If you forget the database password, start the database and update the database login password by ignoring the authorization table method

A, first stop MySQL database service [[email protected] ~]# /etc/init.d/mysqld stopshutting down  MYSQL. SUCCESS!B, ignoring authorization table start MySQL database service [[email protected] ~]# mysqld_safe -- skip-grant-tables --user=mysql &[1] 27447[[email protected] ~]# 160308  23:03:44 mysqld_safe logging to  '/application/mysql-5.5.32/data/mysql-singleton.err '. 160308 23:03:44 mysqld_safe starting mysqld daemon with databases from  /application/mysql-5.5.32/data Note: This example uses the MySQL database Single instance, if for multi-instance need to specify MY.CNF directory C through--defaults-file, no need to enter the password login database [email  protected] ~]# mysql -uoldcatWelcome to the MySQL monitor.   Commands end with ; or \g.Your MySQL connection id is  1server version: 5.5.32 source distributioncopyright  (c)  2000, 2013,  Oracle and/or its affiliAtes. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other names may be trademarks of their respectiveowners . type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql> d, changing the password with the update command (starting the database by ignoring the authorization table is not allowed to update the password with the set command) mysql> update  Mysql.user set password=password ("123456")  where user= "Oldcat"; query ok, 1 row affected  (0.01 sec) rows matched: 1  changed:  1  Warnings: 0mysql> flush privileges; query ok, 0 rows affected  (0.00 SEC) e, restart the MySQL database service, and enter the password form to log in to the database [[email  Protected] ~]# /etc/init.d/mysqld startstarting mysql.  success! [[email protected] ~]# ss -lntup|grep 330tcp    LISTEN     0       50                      *:3306                   *:*       users: (("mysqld", 28000,10)) [[ email protected] ~]# mysql -uoldcat -p123456welcome to the mysql  Monitor.  commands end with ; or \g.your mysql connection id  is 1Server version: 5.5.32 Source distributionCopyright  (c)  2000,  2013, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or  Itsaffiliates. other namEs may be trademarks of their respectiveowners. type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input  statement.mysql>


MySQL Database login password management

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.