Table of Contents
✅ 2. Update phpMyAdmin Config (if needed)
✅ 3. Alternative: Use MySQL Command Line (if phpMyAdmin not accessible)
? Security Tips
Home Database phpMyAdmin How to change the root password in phpMyAdmin

How to change the root password in phpMyAdmin

Jul 28, 2025 am 01:25 AM
root password

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.

How to change the root password in phpMyAdmin

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.

How to change the root password in phpMyAdmin

✅ 1. Change MySQL Root Password via SQL Command

If you already have access to phpMyAdmin as root:

  1. Log in to phpMyAdmin using the current root account.
  2. Click on the SQL tab (top menu).
  3. Run this command:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';

? Replace 'your_new_password' with a strong password.

How to change the root password in phpMyAdmin
  1. 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:

How to change the root password in phpMyAdmin
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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How does phpMyAdmin handle operations on tables with a very large number of columns? How does phpMyAdmin handle operations on tables with a very large number of columns? Jul 02, 2025 am 12:50 AM

phpMyAdminsupportstableswithmanycolumns,butperformanceandusabilitymaydecrease.OpeningtableswithhundredsorthousandsofcolumnscanslowpageloadsandincreasememoryuseduetoHTML/JavaScriptrenderingandcomplexmetadataqueries;considerusingrawSQL,limitingvisiblec

How can I restrict access to phpMyAdmin by IP address or using .htaccess? How can I restrict access to phpMyAdmin by IP address or using .htaccess? Jul 01, 2025 am 12:31 AM

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

How can I optimize a database table (e.g., OPTIMIZE TABLE) using phpMyAdmin? How can I optimize a database table (e.g., OPTIMIZE TABLE) using phpMyAdmin? Jul 11, 2025 am 12:47 AM

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.

How can I add comments to database tables or columns using phpMyAdmin? How can I add comments to database tables or columns using phpMyAdmin? Jul 02, 2025 am 12:04 AM

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

Why might phpMyAdmin display a 'token mismatch' error, and how can it be resolved? Why might phpMyAdmin display a 'token mismatch' error, and how can it be resolved? Jul 05, 2025 am 12:38 AM

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

How does phpMyAdmin's 'Export' option for 'Custom' display differ from 'Quick'? How does phpMyAdmin's 'Export' option for 'Custom' display differ from 'Quick'? Jul 08, 2025 am 12:07 AM

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.

What is the 'Designer' feature in phpMyAdmin, and how can it visualize database schema relationships? What is the 'Designer' feature in phpMyAdmin, and how can it visualize database schema relationships? Jul 08, 2025 am 12:32 AM

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,

How can I export a database or specific tables to a SQL file using phpMyAdmin? How can I export a database or specific tables to a SQL file using phpMyAdmin? Jul 05, 2025 am 12:33 AM

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

See all articles