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

Analysis of MySQL example DTID master-slave principle

Table of contents 1. Basic Concepts of GTID 2. GT...

The corresponding attributes and usage of XHTML tags in CSS

When I first started designing web pages using XH...

Nginx Location Configuration Tutorial from Scratch

Basics The matching order of location is "ma...

Summary of MySQL string interception related functions

This article introduces MySQL string interception...

Detailed analysis of GUID display issues in Mongodb

Find the problem I recently migrated the storage ...

Specific use of MySQL window functions

Table of contents 1. What is a window function? 1...

Installation tutorial of mysql5.7.21 decompression version under win10

Install the unzipped version of Mysql under win10...

JS canvas realizes the functions of drawing board and signature board

This article shares the specific code of JS canva...

How to apply TypeScript classes in Vue projects

Table of contents 1. Introduction 2. Use 1. @Comp...

Tutorial on setting up scheduled tasks to backup the Oracle database under Linux

1. Check the character set of the database The ch...

Detailed explanation of HTML basic tags and structures

1. HTML Overview 1.HTML: Hypertext Markup Languag...

25 Tools to Improve Website Usability and Conversion Rates

For a website, usability refers to whether users c...

How to implement the strategy pattern in Javascript

Table of contents Overview Code Implementation Su...

Implementation of 2D and 3D transformation in CSS3

CSS3 implements 2D plane transformation and visua...

Implementation of HTML to PDF screenshot saving function

Using Technology itext.jar: Convert byte file inp...