Issue :

To list the mysql users and change the password for a particular user via shell.

Solution :

You need to be logged in as ‘root’ in order to do this.

To list the users:

# mysql -u root -p
mysql> SELECT User from mysql.user;

To change the password :

# mysql -u root -p
mysql> SET PASSWORD FOR ‘user’@’hostname’ = PASSWORD(‘newpassword’);
mysql> flush privileges;

Note : When setting database privileges, remember that underscore (_) is a special character, which is like dot (.) in regular expressions.

GRANT ALL ON `db_name`… grants access to many databases, but
GRANT ALL ON `db_name`… grants access to single database named “db_name”.


Shares
Contact Us On WhatsApp