Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql Learning-password Management (default password, change password, solve forgotten password)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. There is no password by default after mysql installation. Log in with default password after initialization and installation. You need to modify the root password immediately.

[root@mysql ~] # cat / root/.mysql_secret-- check the root account password

# The random password set for the root user at Tue Dec 13 18:59:06 2016 (local time): 7MhtyX3aZEl9OUf8

[root@mysql ~] # mysql-uroot-p-- Log in to mysql

Enter password:-- (copy and paste 7MhtyX3aZEl9OUf8 here)

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 2

Server version: 5.6.25

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Note: the appearance of mysql > indicates that everything is going well.

two。 Modify the password

Mysql > SET PASSWORD = PASSWORD ('123456');-- set the password to 123456

[root@mysql etc] # mysql-uroot-p123456-after changing the password, log in

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 39

Server version: 5.6.25 MySQL Community Server (GPL)

Mysql >-login succeeded

3. How to change the password after forgetting the password of the mysql database root.

[root@mysql etc] # service mysql stop-- stop the mysql process

Shutting down MySQL.... SUCCESS!

[root@mysql etc] # mysqld_safe-- skip-grant-tables&-- does not start grant-tables when starting mysql, authorization table. After execution, the following screen appears and a new session starts.

[1] 3574

[root@mysql etc] # 161215 06:13:53 mysqld_safe Logging to'/ var/lib/mysql/mysql.err'.

161215 06:13:53 mysqld_safe Starting mysqld daemon with databases from / var/lib/mysql

[root@mysql ~] # ps-ef | grep mysql-- check whether the mysql process is up

Root 3467 3440 0 05:29 pts/2 00:00:00 mysql-uandy-px xx

Root 3574 2845 0 06:13 pts/0 00:00:00 / bin/sh / usr/bin/mysqld_safe-- skip-grant-tables

Mysql 3677 3574 2 06:13 pts/0 00:00:00 / usr/sbin/mysqld-basedir=/usr-datadir=/var/lib/mysql-plugin-

Mysql > UPDATE user SET password=PASSWORD ('cccccc') WHERE user='root';-- change the root password

Query OK, 4 rows affected (0.04 sec)

Rows matched: 4 Changed: 4 Warnings: 0

Mysql > FLUSH PRIVILEGES;-- permission update

Query OK, 0 rows affected (0.00 sec)

[root@mysql ~] # mysql-uroot-p123456-- Log in with the old password and find it doesn't work, indicating that the password has been updated

Warning: Using a password on the command line interface can be insecure.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

[root@mysql ~] # mysql-uroot-pcccccc-New password login succeeded

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with; or\ g.

Mysql >

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report