How to reset the root password in Linux mysql-5.6

How to reset the root password in Linux mysql-5.6

1. Check whether the MySQL service is started. If it is started, shut down the MySQL service.

Run the command: ps -ef | grep -i mysql

If it is open, run the shutdown command: service mysqld stop

2. Modify the mysql configuration file my.conf

Generally, in the /etc directory, run the command: vi /etc/my.cnf to edit the file

Add a sentence under the [mysqld] tag in the file: skip-grant-tables

Then press wq! to save and exit.

3. Restart the database

Run the command: service mysqld start

4. Restart the database

Run the command: service mysqld start

5. Enter the mysql database

Run the command: mysql -u root

6. Enter the mysql database

Run the command: mysql -u root

7. Change password

Here is how 5.6 does it

Run statement: use mysql;
Continue to run the statement: update mysql.user set password=password('root_password') where user='root';
Replace root_password with your desired password

Here is how 5.7 does it

Run statement: use mysql;
Continue to run the statement: update mysql.user set authentication_string=password('root_password') where user='root';
Replace root_password with your desired password

8. Delete what was added in step 2, restart the server, and then you can log in to the server using the password you just changed.

mysql -u root -p

At this point, everything is finished.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • MySQL multi-instance deployment and installation guide under Linux
  • MySQL 8.0.25 installation and configuration tutorial under Linux
  • How to start multiple MySQL databases on a Linux host
  • Steps and pitfalls of upgrading linux mysql5.5 to mysql5.7
  • Solve the problem of no my.cnf file in /etc when installing mysql on Linux
  • Steps to install MySQL using Docker under Linux
  • Detailed explanation of how to manually deploy a remote MySQL database in Linux
  • Detailed explanation of the idea of ​​using mysqldump+expect+crontab to implement mysql periodic cold backup in linux
  • Aliyun Linux compile and install php7.3 tengine2.3.2 mysql8.0 redis5 process detailed explanation
  • How to implement scheduled backup of MySQL in Linux
  • Use MySQL to open/modify port 3306 and open access permissions in Ubuntu/Linux environment
  • MySQL scheduled backup solution (using Linux crontab)
  • Detailed tutorial on installing MySQL database in Linux environment
  • How to automatically backup mysql remotely under Linux
  • Linux MySQL root password forgotten solution
  • Detailed tutorial on installing mysql-8.0.20 under Linux
  • How to use MyCat to implement MySQL master-slave read-write separation in Linux

<<:  Details on how to write react in a vue project

>>:  How to use mysqldump for full and point-in-time backups

Recommend

How to manage cached pages in Vue

Table of contents Problem 1: Destruction 1. How t...

Example code for implementing a pure CSS pop-up menu using transform

Preface When making a top menu, you will be requi...

Example explanation of MySQL foreign key constraints

MySQL's foreign key constraint is used to est...

What command is better for fuzzy searching files in Linux?

1. Introduction This article mainly explains how ...

Solution to index failure in MySQL due to different field character sets

What is an index? Why create an index? Indexes ar...

Some suggestions for Linux system optimization (kernel optimization)

Disable swap If the server is running a database ...

Detailed process of installing Presto and connecting Hive in Docker

1. Introduction Presto is an open source distribu...

Will mysql's in invalidate the index?

Will mysql's IN invalidate the index? Won'...

Turn off the AutoComplete function in the input box

Now we can use an attribute of input called autoco...

A brief discussion of four commonly used storage engines in MySQL

Introduction to four commonly used MySQL engines ...

Summary of knowledge points about covering index in MySQL

If an index contains (or covers) the values ​​of ...