On an Ubuntu server, you must adjust both the phpMyAdmin configuration and the MySQL user’s settings in order to alter the root user’s username. The steps to do that are as follows
- Log in to your Ubuntu server.
- Log in to MySQL as the root user. You’ll need to provide the MySQL root password when prompted:
mysql -u root -p
3. In MySQL, change the root user’s username to the new desired username. Replace new_username
with your preferred username:
RENAME USER 'root'@'localhost' TO 'myhospitalnow'@'localhost';

4. After renaming the user, you need to update the user privileges. Replace new_username
in the following command with your new username:
UPDATE mysql.user SET user = 'myhospitalnow' WHERE user = 'root';

5. Flush the privileges to apply the changes :
FLUSH PRIVILEGES;

6. Exit the MySQL shell:
EXIT;
7. Next, open the phpMyAdmin configuration file in a text editor. On Ubuntu, it’s typically located at /etc/phpmyadmin/config-db.php
. You can use nano
or your preferred text editor:
sudo nano /etc/phpmyadmin/config-db.php
8. Locate the lines defining the database username and password. They should look like this:
$dbuser = 'root';
$dbpass = 'mysql_root_password';
Change the username from root
to your new username:
$dbuser = 'myhospitalnow';
9. Save the changes and exit the text editor.
10. Restart the Apache web server to apply the changes:
sudo service apache2 restart
The new username should now be used in place of root in your phpMyAdmin configuration. With the new username and password, you may log into phpMyAdmin. When login in, be sure to use the new username and password.