Detail Centos7 Modify mysql Specified User Password

  • 2021-06-28 14:20:24
  • OfStack

This paper describes how Centos7 modifies the password of the specified mysql user as follows:

1. Log on to mysql or mariadb (either option 1)


[root@localhost ~]# mysql -u root 
[root@localhost ~]# mysql -uroot -p

2. Switch to a database that stores user names and passwords


MariaDB [mysql]> use mysql; Enter and the following will be displayed 
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
Database changed

3. Modifying the password and encrypting it with the password() function is essentially executing the sql statement to update the password of the specified user


MariaDB [mysql]> update user set password=password(' New password ') where user=' User name to update password '; Enter 
 * -> ;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 5 Changed: 0 Warnings: 0

4. Refresh the list of user rights


MariaDB [mysql]> flush privileges; Enter 
Query OK, 0 rows affected (0.00 sec)

5. Exit mysql login


MariaDB [mysql]> quit
Bye

6. Restart mysql or mariadb services


[root@localhost ~]# service mysqld restart( restart mysql)
[root@localhost ~]# service mariadb restart( restart mariadb)

Related articles: