Different ways to Reset user password in Mariadb mysql.

Today in this post, we will see different ways to reset a mysql user password in MariaDB.

Lets first login into mysql database from root.

I. Connect to mysql/MariaDB with root user.

[root@ngelinux001 objects]# mysql -h localhost -u root -pHello@123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6365371
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> help

General information about MariaDB can be found at
MariaDB Foundation
List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear the current input statement. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mysql server, display result vertically. exit (\q) Exit mysql. Same as quit. go (\g) Send command to mysql server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mysql prompt. quit (\q) Quit mysql. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents'

 

II. Check available users.

MariaDB > connect oracledb
MariaDB [oracledb]> SELECT User FROM mysql.user
    -> ;
+----------+
| User     |
+----------+
| dbuser  |
| root     |
| dbuser  |
| root     |
| dbuser  |
| dbuser  |
| dbuser  |
| dbuser  |
| root     |
|          |
| ndoutils |
| root     |
| dbuser  |
|          |
| root     |
+----------+
15 rows in set (0.00 sec)

MariaDB [oracledb]>

 

III. Set password using “SET PASSWORD” command.

MariaDB [oracledb]> SET PASSWORD FOR dbuser = PASSWORD('H@llo123123');
Query OK, 0 rows affected (0.01 sec)

 

IV. Setting password using update command.

MariaDB [oracledb]> update mysql.user set password=PASSWORD('H@llo123123') where user='dbuser';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 7  Changed: 0  Warnings: 0

MariaDB [oracledb]> flush privileges
    -> ;
Query OK, 0 rows affected (0.03 sec)

MariaDB [oracledb]>
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments