Multiple methods to modify MySQL root password (recommended)

Multiple methods to modify MySQL root password (recommended)

Method 1: Use the SET PASSWORD command

MySQL -u root
  mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

Method 2: Using mysqladmin

  mysqladmin -u root password "newpass"

If the root password has been set, use the following method

mysqladmin -u root password oldpass "newpass"

Method 3: Use UPDATE to edit the user table directly

 mysql -u root
  mysql> use mysql;
  mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
  mysql> FLUSH PRIVILEGES;

When you lose your root password, you can

mysqld_safe --skip-grant-tables&
  mysql -u root mysql
  mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';
  mysql> FLUSH PRIVILEGES;

The above are the various methods of changing the root password of MySQL that I introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and I 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:
  • MySQL - 4 ways to change the root password (taking Windows as an example)
  • What should I do if I forget my MySQL password? How to reset MySQL root password
  • Solution to forgetting the root password of mysql under windows
  • How to view or modify the root password of MySQL if it is forgotten (with pictures and text)
  • How to forget the root password in MySQL 5.7 and change the root password in MySQL 5.7
  • The perfect solution for forgetting the root password of Mysql
  • How to view the root password for MySQL connection
  • Detailed explanation of the idea of ​​installing mysql8.0.11 and changing the root password and connecting navicat for mysql
  • 4 ways to modify MySQL root password (summary)
  • How to forget the root password in Mysql8.0.13 under Windows 10 system

<<:  Native JavaScript implementation of progress bar

>>:  How to use Docker container to access host network

Recommend

Detailed explanation of CocosCreator message distribution mechanism

Overview This article begins to introduce content...

MySQL 8.0.23 Major Updates (New Features)

Author: Guan Changlong is a DBA in the Delivery S...

Mysql | Detailed explanation of fuzzy query using wildcards (like,%,_)

Wildcard categories: %Percent wildcard: indicates...

Example of implementing login effect with vue ElementUI's from form

Table of contents 1. Build basic styles through E...

Detailed example of MySQL joint table update data

1.MySQL UPDATE JOIN syntax In MySQL, you can use ...

The principle and implementation of js drag effect

The drag function is mainly used to allow users t...

Example code for css flex layout with automatic line wrapping

To create a flex container, simply add a display:...

Solution to the problem of not finding Tomcat configuration in Intelli Idea

I joined a new company these two days. The compan...

Detailed analysis of classic JavaScript recursion case questions

Table of contents What is recursion and how does ...

Pure js to achieve typewriter effect

This article example shares the specific code of ...

How to view MySQL links and kill abnormal links

Preface: During database operation and maintenanc...

Use IISMonitor to monitor web pages and automatically restart IIS

Table of contents 1. Tool Introduction 2. Workflo...