In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the linux to connect to the MySQL password forgot the solution, the contents of the article are carefully selected and edited by the author, with a certain pertinence, for everyone's reference significance is still relatively great, the following with the author to understand the linux connection MySQL password forgot the solution.
1. First, make sure that the CVM is in a secure state, that is, no one can connect to the MySQL database arbitrarily.
Because during the period of resetting the root password for MySQL, the MySQL database is completely unprotected by the password
In this state, other users can log in and modify MySQL information at will. You can use the MySQL pair
The external port is closed, and the quasi-security of the cloud server is realized by stopping Apache and all user processes.
Status. The safest state is to operate on the Console of the CVM and unplug the network cable.
If you rent a cloud server on the Internet, we will modify it remotely.
2. Modify the login settings of MySQL:
# vim / etc/my.cnf
Add a sentence to the paragraph of [mysqld]: skip-grant-tables
For example:
[mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
Skip-grant-tables
Save and exit vi.
3. Restart mysqld
# service mysqld restart
Stopping MySQL: [OK]
Starting MySQL: [OK]
Or appear:
Redirecting to / bin/systemctl restart mysqld.service
4. Log in and change the root password of MySQL
# mysql
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or'\ h' for help. Type'\ c'to clear the buffer.
Mysql > USE mysql
Database changed
Mysql > UPDATE user SET Password = password ('123456') WHERE User =' root'; (note that within the single quotation marks in parentheses is the password you want to reset)
Query OK, 0 rows affected (0.00 sec)
Rows matched: 5 Changed: 0 Warnings: 0
If there is an error
Replace it with the command: UPDATE user SET authentication_string = password ('123') WHERE user =' root'
Mysql > flush privileges
Query OK, 0 rows affected (0.01 sec)
Mysql > quit
Bye
5. Modify the login settings of MySQL
# vim / etc/my.cnf
Delete the skip-grant-tables just added in the paragraph of [mysqld]
Save and exit vim
6. Restart mysqld
# service mysqld restart
Stopping MySQL: [OK]
Starting MySQL: [OK]
Or:
Redirecting to / bin/systemctl restart mysqld.service
7. Check whether the new password is valid
Enter mysql-u root-p enter
Then enter the new password and enter, as shown in the figure below.
After reading the above about the password to connect to MySQL in linux and forgot the solution, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.