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

Six border transition effects implemented by CSS3

Six effectsImplementation Code html <h1>CSS...

TypeScript Mapping Type Details

Table of contents 1. Mapped Types 2. Mapping Modi...

Detailed explanation of how to connect Java to Mysql version 8.0.18

Regarding the connection method between Java and ...

Summary of 6 skills needed to master web page production

It has to be said that a web designer is a general...

Detailed explanation of the usage and difference between nohup and & in Linux

Example: We use the Python code loop_hello.py as ...

Introducing icons by implementing custom components based on Vue

Preface In project development, there are many wa...

Not all pop-ups are rogue. Tips on designing website pop-ups

Pop-up news is common in domestic Internet servic...

Steps to create a Vite project

Table of contents Preface What does yarn create d...

Understand the principle of page replacement algorithm through code examples

Page replacement algorithm: The essence is to mak...

Detailed explanation of reduce fold unfold usage in JS

Table of contents fold (reduce) Using for...of Us...

Nginx reverse proxy learning example tutorial

Table of contents 1. Reverse proxy preparation 1....