MySQL is a popular open-source database management system that can store and manipulate data. To access a MySQL database, you need to create a user account and assign it a password. The process of creating a new user and database is also being done automatically upon a creation of cPanel account and when adding domains to said account. Resetting the MySQL user password can be very simple and can be performed using two methods as listed below in this Resetting MySQL User Password guide.
Changing MySQL User Password Using WHM/cPanel
This is the recommended method when performing a MySQL user password change when your server contains a cPanel installation.
- Login to your WHM/cPanel and search for “Change MySQL® User Password“.
- Select the MySQL user you wish to change the password.
- Ensure to type a password with a strength score of at least 80%, as shown below and press the “Change Password” once completed.
Changing MySQL User Password Using the Command Line Interface
The following steps will describe the process involved in changing the MySQL user password via the command line once you’ve logged into your server via SSH or by using the Console feature in the customer portal.
- Login to the server as the “root” user.
- Type the command mysql -u root -h localhost -p to login to MySQL as the “root” user.
- Enter the “root” user MySQL password to login.
- If you are unsure of what the “root” user password is, you can use the command my_print_defaults -s client to view it in the main command prompt.
- Now that you are logged in to MySQL as “root” user.
- Run command SELECT user FROM mysql.user; to view a full list of available users.
- Use the following command to alter the password ALTER USER ‘pascalsuissa’@’localhost’ IDENTIFIED BY ‘MyNewPasswordis1234!’;
- “pascalsuissa” is the username.
- “MyNewPasswordis1234” is the password.
-
Once the command has completed running, the prompt will display a “Query OK” message, indicating that the password change is now complete.
-Written by Pascal Suissa