How to change mysql password under Centos

How to change mysql password under Centos

1. Modify MySQL login settings:

# vim /etc/my.cnf

Add a sentence: skip-grant-tables

like:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

2. Restart mysql

# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

3. Change Password

mysql> USE mysql;
Database changed
mysql> UPDATE user SET Password = password ('new password') WHERE User = 'root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit

4. Modify the configuration file you just modified

# vim /etc/my.cnf

5. Restart mysql

# service mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

The above is the method of changing the MySQL password under CentOS introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • How to quickly modify the root password under CentOS8
  • CentOS 7 set grub password and single user login example code
  • How to change the password of mysql5.7.20 under linux CentOS 7.4
  • How to reset the root password in CentOS7
  • How to modify the root password of MySQL in CentOS environment
  • Solution to the problem of still having to enter a password after configuring ssh password-free login in centos
  • How to install and modify the initial password of mysql5.7.18 under Centos7.3
  • CentOS 7 Forgot Password Solution Process Diagram

<<:  What are the new features of Apache Spark 2.4, which will be released in 2018?

>>:  Javascript to achieve the effect of closing advertisements

Recommend

css3 animation ball rolling js control animation pause

CSS3 can create animations, which can replace man...

How to add rounded borders to div elements

As shown below: CSS CodeCopy content to clipboard...

jQuery implements font size adjustment case

This article shares the specific code of jQuery t...

How to set up scheduled tasks in Linux and Windows

Table of contents Linux 1. Basic use of crontab 2...

How to implement DIV's blur function

Use anti-shake to make DIV disappear when the mou...

CSS3 flexible box flex to achieve three-column layout

As the title says: The height is known, the width...

Tutorial on how to create a comment box with emoticons using HTML and CSS

HTML comment box with emoticons. The emoticons ar...

Talk about nextTick in Vue

When the data changes, the DOM view is not update...

select the best presets to create full compatibility with all browsersselect

We know that the properties of the select tag in e...

Basic JSON Operation Guide in MySQL 5.7

Preface Because of project needs, the storage fie...

Implementation of Webpack3+React16 code splitting

Project Background Recently, there is a project w...

How to use localStorage in JavaScript

If you are a developer looking to get into the wo...

Detailed explanation of Linux netstat command

Table of contents Linux netstat command 1. Detail...