Zero logo

MySQL - Change Password

There are three methods for changing the MySQL root password: by UniController, phpMyAdmin or MySQL Console. The easiest method is to use UniController, which is fully automated. Other methods require a certain amount of typing and editing, and are more error-prone.

Set New MySQL root user password using UniController

Starting UniController provides the first opportunity to change the current root password. It is highly recommended that you set this password at the first opportunity.

Alternatively, you can skip setting a new MySQL root password and run this menu option later using:

MySQL > Change MySQL root password

  • The Set New MySQL Password menu opens (see image on right).
  • Enter a new password (A).
  • Click the OK button (B).

Note: Clicking the Cancel button, no action is taken. You can set the password later.

  Set root user MySQL password

Set New MySQL root user password using phpMyAdmin

Setting a new MySQL root password using phpMyAdmin requires two root accounts to be changed along with one configuration file.
Note: The following assumes the current password is root12 and the new password is root123; substitute for these as appropriate.

First, start both servers using UniController and then start phpMyAdmin. To change the password, proceed as follows:

  1. From the top menu bar of phpMyAdmin, click the User accounts (1) button. The User accounts overview page opens, as shown on right:
  2. Click Edit Privileges (2) next to user pma. This opens a new page: Edit Privileges: User account
       ◦ Click on Change password.
       ◦ Enter new root password:
         For example, root123 (4). Re-type password (5).
       ◦ Click Go (6) to update the user's password.
  3. Repeat step 2 for user root (3)
  4. Navigate to the end of the User account overview page and click Reload the privileges link.

Note: Do not stop the MySQL server at this point.

  Change MySQL root password phpMyAdmin
  1. Edit file C:\UniServerZ\htpasswd\passwd.txt
    Replace root12 with the new root password root123.

Note: Perform a quick test. Clear your browser's cache and restart the servers. Run phpMyAdmin and verify that the MySQL server is accessible.

  Change MySQL root password phpMyAdmin

Note: The above root user accounts all use the same root password. This is purely for convenience and one of consistency.

Set New MySQL root user password using MySQL Console

Setting a new MySQL root password using MySQL Console requires two root accounts to be changed along with one configuration file.
Note: The following assumes the current password is root123 and the new password is root1234; substitute for these as appropriate.

First, start both servers using UniController and proceed as follows:

  1. Start MySQL Console: click MySQL Console button
  2. At the MySQL prompt, type the following:
    mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('root1234');
    mysql> SET PASSWORD FOR 'pma'@'127.0.0.1'  = PASSWORD('root1234');
    mysql> FLUSH PRIVILEGES;
    mysql> exit;
    
    Results for steps 1 and 2 are shown on right.
  3. Edit file C:\UniServerZ\htpasswd\passwd.txt
    Replace root123 with the new root password root1234.

Note: Perform a quick test. Clear your browser's cache and restart the servers. Run phpMyAdmin and verify that the MySQL server is accessible.

 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: x.x.x MySQL Community Server - GPL

Copyright (c) (...), Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('root1234');
Query OK, 0 rows affected (0.11 sec)
mysql> SET PASSWORD FOR 'pma'@'127.0.0.1'  = PASSWORD('root1234');
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.44 sec)
mysql> exit
Bye

C:\UniServerZ\core\mysql\bin>

Related topics

Restore MySQL root user password
MySQL Console


--oOo--