How to change the root password in phpMyAdmin
To change the root password in phpMyAdmin, execute ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password'; in the SQL tab after logging in, ensuring you update the password for all relevant hosts like 'root'@'127.0.0.1' if present. 2. If phpMyAdmin uses config authentication, update the password in /etc/phpmyadmin/config.inc.php or switch to cookie-based authentication by setting $cfg['Servers'][$i]['auth_type'] = 'cookie'; for better security. 3. If phpMyAdmin is inaccessible, use the MySQL command line with sudo mysql -u root -p and run the ALTER USER command followed by FLUSH PRIVILEGES; to apply changes. Always restart the web server if needed and avoid storing passwords in config files by using cookie authentication, concluding the process securely and completely.
Changing the root password in phpMyAdmin isn't done directly within phpMyAdmin itself — it's actually a MySQL/MariaDB user password change, and phpMyAdmin is just a web interface to manage the database. Here's how to properly change the root password for your MySQL server, which will affect access through phpMyAdmin.

✅ 1. Change MySQL Root Password via SQL Command
If you already have access to phpMyAdmin as root:
- Log in to phpMyAdmin using the current root account.
- Click on the SQL tab (top menu).
- Run this command:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';
? Replace
'your_new_password'
with a strong password.
- Click Go to execute.
✅ This updates the root password for connecting from localhost.
⚠️ Note: Some setups may use
'root'@'127.0.0.1'
or'root'@'::1'
. If you get an error, check the exact user host with:SELECT User, Host FROM mysql.user WHERE User = 'root';And run
ALTER USER
for each relevant host.
✅ 2. Update phpMyAdmin Config (if needed)
After changing the root password, you don’t need to change anything in phpMyAdmin if you're logging in manually (i.e., using "root" and the new password).
But if phpMyAdmin uses config authentication (auto-logs in without asking), you may need to update its configuration:
? File:
/etc/phpmyadmin/config.inc.php
(path varies by OS/install method)
Look for:
$cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'old_password';
Change the password line:
$cfg['Servers'][$i]['password'] = 'your_new_password';
Or better, change auth_type
to cookie
for security:
$cfg['Servers'][$i]['auth_type'] = 'cookie';
Now phpMyAdmin will prompt for login credentials instead of storing them.
✅ 3. Alternative: Use MySQL Command Line (if phpMyAdmin not accessible)
If you can't log in to phpMyAdmin, use the terminal:
sudo mysql -u root -p
Then run the same ALTER USER
command:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password'; FLUSH PRIVILEGES;
Exit with exit
.
? Security Tips
- Avoid using root for everyday tasks. Create a separate admin user.
- Use
auth_type = 'cookie'
in phpMyAdmin so passwords aren’t stored in config files. - Restart your web server if changes don’t take effect:
sudo systemctl restart apache2 # or sudo systemctl restart nginx
Basically, changing the root password is a MySQL operation — phpMyAdmin just lets you run it. Just make sure the new password is reflected in any automated login configs.
The above is the detailed content of How to change the root password in phpMyAdmin. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

phpMyAdminsupportstableswithmanycolumns,butperformanceandusabilitymaydecrease.OpeningtableswithhundredsorthousandsofcolumnscanslowpageloadsandincreasememoryuseduetoHTML/JavaScriptrenderingandcomplexmetadataqueries;considerusingrawSQL,limitingvisiblec

TorestrictaccesstophpMyAdminbyIPaddress,youcanuseeitherthe.htaccessfileorApache’sconfiguration.1.For.htaccessmethod,navigatetothephpMyAdmindirectory,editorcreatea.htaccessfile,andadd"Requireip[your-ip]"forApache2.4 or"OrderDeny,Allow&q

Optimizing database tables can improve performance. The specific steps are as follows: 1. Log in to phpMyAdmin and select the corresponding database; 2. Select the table to be optimized from the table list, usually a table with high-frequency insertion, update or delete operations; 3. Select "Optimizetable" in the "Withselected:" menu and confirm execution. During optimization, MySQL rebuilds the table to reduce disk I/O, update index statistics, and free up space occupied by deleted or modified data, but this operation temporarily locks the table and is recommended during low peak periods. Not all tables need to be optimized regularly. It is more appropriate to optimize frequently changed tables once a month, and other tables may depend on the situation.

Yes,youcanaddcommentstobothtablesandcolumnsinphpMyAdmin.1.Toaddatablecomment,openthetable'sstructurepage,clickthe"Operations"tab,enteryourcommentinthe"Tablecomment"field,andclick"Go".2.Toaddcolumncomments,gotothetablestr

The"tokenmismatch"errorinphpMyAdministypicallycausedbysessionexpiration,outdatedlinks,cookieissues,orconfigurationproblems.1.Loggingoutandbackinrefreshessessionsandtokens.2.Clearingbrowsercacheandcookies,especiallyforthephpMyAdmindomain,res

Quick and Custom are two options for phpMyAdmin to export databases. Quick is suitable for fast backup or migration of data, exported in the default SQL format without additional settings; while Custom provides advanced control functions, supports selection of file formats, compression methods, data structures, etc., suitable for scenarios where specific configurations are required or are ready to be delivered to other systems.

The "Designer" feature of phpMyAdmin is a visualization tool that helps users understand and manage relationships between tables in MySQL or MariaDB databases. It graphically displays table structure, foreign key connections, supports custom tags and annotations, provides an intuitive database schema view, and allows users to interactively adjust layouts. To use this feature, make sure the database uses the InnoDB engine and has foreign key constraints defined, then you can enter the interface by selecting the database and clicking the "Designer" tab at the top. In order to effectively use Designer, you should ensure that foreign keys are correctly set, use drag and drop functions to optimize layout, save the current arrangement, and add comments to improve readability. This tool is debugging complex queries,

Yes,youcanexportadatabaseorspecifictablestoaSQLfileusingphpMyAdmin.Toexportanentiredatabase,accessphpMyAdminviayourhostingpanel,selectthedatabase,click"Export",choose"Quick"and"SQL"format,thendownloadthefile.Forspecifict
