How to install phpMyAdmin on Ubuntu
Update the system using sudo apt update and optionally upgrade packages. 2. Install phpMyAdmin with sudo apt install phpmyadmin, selecting apache2 as the web server and configuring the database with a strong password. 3. Enable the Apache rewrite module using sudo a2enmod rewrite and restart Apache. 4. Secure access by either changing the URL alias to a custom name like /mydbadmin or adding HTTP authentication with htpasswd. 5. Adjust PHP settings for larger imports by modifying upload_max_filesize, post_max_size, memory_limit, and max_execution_time in the php.ini file. 6. Access phpMyAdmin via the configured URL and log in with valid MySQL credentials, preferably using a dedicated non-root user. Troubleshoot 404 errors by enabling the phpmyadmin configuration and resolve login issues by ensuring proper MySQL user privileges, resulting in a fully functional and secured phpMyAdmin installation.
Installing phpMyAdmin on Ubuntu is straightforward, especially if you already have a LAMP (Linux, Apache, MySQL, PHP) stack set up. Here’s a step-by-step guide to get it working on Ubuntu 20.04 or 22.04.

1. Update Your System
Before installing anything, make sure your package list is up to date:
sudo apt update
Optional: upgrade existing packages:

sudo apt upgrade -y
2. Install phpMyAdmin
Run the following command to install phpMyAdmin:
sudo apt install phpmyadmin
During installation, you’ll see a configuration screen. Here’s what to do:

- Choose the web server: Use the spacebar to select
apache2
(highlight it and press space), then hit Tab to "OK" and press Enter. - Configure database for phpMyAdmin with dbconfig-common? Select Yes.
- Enter a password for the phpMyAdmin database: You’ll be prompted to set a strong password. Remember it or leave it blank to generate one automatically.
⚠️ If the configuration screen doesn’t appear, you can reconfigure it later:
sudo dpkg-reconfigure phpmyadmin
3. Enable Apache Rewrite Module (Recommended)
To ensure clean URLs and proper functionality:
sudo a2enmod rewrite
Then restart Apache:
sudo systemctl restart apache2
4. Secure phpMyAdmin Access (Optional but Recommended)
By default, phpMyAdmin is accessible at http://your-server-ip/phpmyadmin
, which can be a security risk.
Option A: Change the URL path (add alias protection)
Edit the Apache configuration:
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Look for the line:
Alias /phpmyadmin /usr/share/phpmyadmin
Change /phpmyadmin
to something less guessable, like:
Alias /mydbadmin /usr/share/phpmyadmin
Save (Ctrl O
, then Enter
), exit (Ctrl X
), then restart Apache:
sudo systemctl restart apache2
Now access it via: http://your-server-ip/mydbadmin
Option B: Add password protection
You can add HTTP authentication using .htpasswd
.
Install Apache utilities if not already:
sudo apt install apache2-utils
Create a password file and user:
sudo htpasswd -c /etc/phpmyadmin/.htpasswd yourusername
Edit the phpMyAdmin config:
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Inside the <Directory /usr/share/phpmyadmin>
block, add:
AuthType Basic AuthName "Restricted Access" AuthUserFile /etc/phpmyadmin/.htpasswd Require valid-user
Restart Apache:
sudo systemctl restart apache2
Now you’ll need to log in twice: first with the HTTP password, then MySQL credentials.
5. Adjust PHP Settings (if needed)
If you’re importing large databases, increase limits in PHP config:
sudo nano /etc/php/*/apache2/php.ini
Replace
*
with your PHP version (e.g.,8.1
or8.2
).
Modify these values:
upload_max_filesize = 100M post_max_size = 100M memory_limit = 256M max_execution_time = 300
Save and restart Apache:
sudo systemctl restart apache2
6. Access phpMyAdmin
Open your browser and go to:
http://your-server-ip/phpmyadmin
Or, if you changed the alias:
http://your-server-ip/mydbadmin
Log in with:
- Username: Your MySQL user (e.g.,
root
or a custom user) - Password: The corresponding MySQL password
? Note: Using
root
remotely via phpMyAdmin is discouraged. Create a dedicated user with limited privileges when possible.
Troubleshooting Tips
- 404 Error? Make sure the Apache config is enabled:
sudo a2enconf phpmyadmin sudo systemctl restart apache2
- Login failed? Ensure the MySQL user has proper privileges. You may need to create a user specifically for web access:
CREATE USER 'pmauser'@'localhost' IDENTIFIED BY 'strongpassword'; GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost'; FLUSH PRIVILEGES;
That’s it. phpMyAdmin should now be installed and accessible. Keep it updated and avoid exposing it directly to the internet without protection.
The above is the detailed content of How to install phpMyAdmin on Ubuntu. 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)

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.

phpMyAdmindisplaysandallowseditingofcolumndefaultsandauto-incrementsettingsthroughthetablestructureview.1.Defaultvaluesareshowninthe"Default"column,whereyoucaneditthemviadropdownorinputfield,supportingNULL,CURRENT_TIMESTAMP,USER(),orcustomv

UsingphpMyAdminonaproductionserverispossiblebutrequiresstrictsecuritymeasures.1.Secureaccessbyusingstrongauthentication,limitingIPaccess,enabling2FA,andchangingthedefaultURL.2.Keepitupdatedthroughofficialsources,applysecuritypatches,andmonitorforCVEs

phpMyAdmindoesnotimposeahardlimitondatabasesortables,butperformancedegradesbasedonserverresources.1.AvailableRAM,CPUpower,anddiskI/Ospeedsignificantlyimpactusability.2.Modestserverstypicallyhandle50–100databases,whilehigh-performancesetupscanmanagehu

To disable specific features or tabs in phpMyAdmin, it can be done by modifying the configuration file. 1. Edit the config.inc.php file and use settings such as $cfg['ShowPhpInfo']=false; to hide the specified tag; 2. Restrict access based on user roles, control the visibility of functions by creating MySQL users with limited permissions and configuring parameters such as $cfg['AllowUserDropDatabase']=false; to control the visibility of functions; 3. Turn off unnecessary functions, such as setting $cfg['AllowArbitraryServer']=false; to disable any server input; 4. Optionally, hide with custom themes

The way phpMyAdmin handles BLOB data is practical but limited. 1. When viewing the BLOB column, placeholders such as [BLOB-25B] are usually displayed to avoid directly rendering large or unreadable content; for text-type BLOBs (such as JSON), you can click to view the specific content. 2. When editing the BLOB field, small text-type BLOBs can be edited through text boxes, while large or binary BLOBs (such as pictures) cannot be edited inline and need to be replaced by downloading or uploading files. 3. Configuration options $cfg['DisplayBinaryAsHex'], $cfg['DisplayBlob'] and $cfg['SaveCellsAtOnce'] can control BL

Checkyourinstallationmethodtodeterminethecorrectupdateapproach.2.Forpackagemanagerinstallations,usesudoaptupdateandsudoaptupgradephpmyadminorreinstall.3.Formanualupdates,downloadthelatestversionfromphpmyadmin.net,backupyourcurrentinstallationandconfi

The overhead of tables is generated by MySQL internal data management. Common reasons are: 1. Delete a large number of rows; 2. Updating variable-length fields leads to reduced space; 3. Frequent addition and deletion operations. phpMyAdmin displays this information to prompt for tables that can be optimized. The fix is to use the "Optimizetable" function, which rebuilds tables and reclaims space, suitable for MyISAM and InnoDB engines, and it is recommended to perform periodically to maintain database efficiency.
