Table of Contents
1. Update Your System
2. Install phpMyAdmin
3. Enable Apache Rewrite Module (Recommended)
4. Secure phpMyAdmin Access (Optional but Recommended)
Option A: Change the URL path (add alias protection)
Option B: Add password protection
5. Adjust PHP Settings (if needed)
6. Access phpMyAdmin
Troubleshooting Tips
Home Database phpMyAdmin How to install phpMyAdmin on Ubuntu

How to install phpMyAdmin on Ubuntu

Jul 29, 2025 am 01:49 AM

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.

How to install phpMyAdmin on Ubuntu

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.

How to install phpMyAdmin on Ubuntu

1. Update Your System

Before installing anything, make sure your package list is up to date:

sudo apt update

Optional: upgrade existing packages:

How to install phpMyAdmin on Ubuntu
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:

How to install phpMyAdmin on Ubuntu
  • 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

To ensure clean URLs and proper functionality:

sudo a2enmod rewrite

Then restart Apache:

sudo systemctl restart apache2

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 or 8.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!

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)

Hot Topics

PHP Tutorial
1504
276
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 does phpMyAdmin display and allow editing of DEFAULT values and AUTO_INCREMENT properties for columns? How does phpMyAdmin display and allow editing of DEFAULT values and AUTO_INCREMENT properties for columns? Jul 23, 2025 am 04:19 AM

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

Is it advisable to use phpMyAdmin on a production server, and what precautions should be taken? Is it advisable to use phpMyAdmin on a production server, and what precautions should be taken? Jul 16, 2025 am 12:03 AM

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

What are the limitations on the number of databases or tables phpMyAdmin can effectively display and manage? What are the limitations on the number of databases or tables phpMyAdmin can effectively display and manage? Jul 12, 2025 am 12:57 AM

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

How can I disable specific features or tabs in phpMyAdmin for security or simplicity? How can I disable specific features or tabs in phpMyAdmin for security or simplicity? Jul 14, 2025 am 12:21 AM

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

How does phpMyAdmin handle binary data (BLOBs) when displaying or editing table content? How does phpMyAdmin handle binary data (BLOBs) when displaying or editing table content? Jul 20, 2025 am 04:12 AM

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

How to update phpMyAdmin How to update phpMyAdmin Aug 02, 2025 am 06:57 AM

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

What does the 'Overhead' column signify in phpMyAdmin's table overview? What does the 'Overhead' column signify in phpMyAdmin's table overview? Jul 14, 2025 am 12:33 AM

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.

See all articles