Home > Database > Mysql Tutorial > What should I do if I forget mysql default password under centos?

What should I do if I forget mysql default password under centos?

青灯夜游
Release: 2022-03-30 15:50:25
Original
7406 people have browsed it

Solution: 1. Use the "grep 'temporary password' /var/log/mysqld.log" command to retrieve the initial password during installation; 2. Modify the configuration file "my.cnf" to avoid Log in to the mysql server with your password and use the update command to set a new password.

What should I do if I forget mysql default password under centos?

The operating environment of this tutorial: CentOS 6 system, mysql8 version, Dell G3 computer.

Solution to the forgotten mysql default password under centos

Method 1. Retrieve the initial password during installation:

Execute the following command directly

grep 'temporary password' /var/log/mysqld.log
Copy after login

What should I do if I forget mysql default password under centos?

##Method 2. Configure the my.cnf file, log in to the mysql server without a password, and use the update command Set a new password

1. Modify the configuration file and log in to the mysql server without a password

#vim /etc/my.cnf(Note: windows The modification below is my.ini)

Add any line after [mysqld]

explicit_defaults_for_timestamp=true
skip-grant-tables
Copy after login

Save and exit

Restart mysql

service mysqld restart
Copy after login

Log in to mysql directly

mysql -uroot
Copy after login

What should I do if I forget mysql default password under centos?

2. Change password

use mysql
update user set authentication_string=password(“123456”) where user=“root”;
Copy after login

What should I do if I forget mysql default password under centos?

(Recommended tutorial:

mysql video tutorial)

The above is the detailed content of What should I do if I forget mysql default password under centos?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template