Get the App
SLTechnology News&Howtos  ›  Database  › 

What are the useful ways to change the root password in MySQ

Shulou Source: shulou.com Published: 2022-06-01 18:42:36 10月14日 Update

This article mainly introduces what MySQ has to use to modify the root password, the contents of the article are carefully selected and edited by the author, with a certain pertinence, the reference significance for everyone is still relatively great, the following with the author to understand what good ways to modify the root password MySQ.

Method 1: use the SET PASSWORD command

Mysql-u root

Mysql > SET PASSWORD FOR 'root'@'localhost' = PASSWORD (' newpass')

Mysql > quit; / / exit the mysql console

After setting the password, test login:

Mysql-u root-p "newpass" / /-p and password cannot have spaces

Or enter mysql-u root-p to enter and let the system prompt for the password.

Method 2: use mysqladmin

Mysqladmin-u root password "newpass"

If root has already set a password, use the following methods

Mysqladmin-u root password oldpass "newpass"

Method 3: edit the user table directly with UPDATE

Mysql-u root

Mysql > use mysql

Mysql > UPDATE user SET Password = PASSWORD ('newpass') WHERE user =' root'

Mysql > FLUSH PRIVILEGES

You can do this when you lose your root password

Mysqld_safe-skip-grant-tables&

Mysql-u root mysql

Mysql > UPDATE user SET password=PASSWORD ("new password") WHERE user='root'

Mysql > FLUSH PRIVILEGES

After reading the above about MySQ what good ways to change the root password, many readers must have some understanding, if you need to get more industry knowledge and information, you can continue to follow our industry information column.

Tags: Password method easy to use author industry input between information content command meaning console article time more friends column knowledge system reader Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Docker Redmi Linux OPPO Reno