Introduction Show
phpMyAdmin is a free application for managing a MySQL server. Installing phpMyAdmin allows management of MySQL databases through a user-friendly interface, instead of entering commands into the terminal. This guide will help you install phpMyAdmin on Ubuntu 18.04 or 20.04, with additional security features. Prerequisites
This guide assumes you’re installing to a local system. If you need to set up encryption or security certificates for configuring a remote server, please refer to this guide on open SSL. Note: If you’re connecting to a remote server, there’s a security risk in running phpMyAdmin over plain HTTP. A plain HTTP connection is unencrypted and can be intercepted. Also, since phpMyAdmin is a popular application, it’s a common vector for attacks. Installing phpMyAdmin on UbuntuStep 1: Add and Update Software RepositoriesSome Ubuntu 18.04 installations are not configured with the software repositories for phpMyAdmin. To add them, open a terminal window and enter the following command:
If the repository is already enabled, skip to the next step. If not, the system asks for your password – enter it, then make sure the process completes successfully. Once completed, refresh the software lists by entering the following commands:
Allow the operation to finish. Step 2: Install phpMyAdminTo install phpMyAdmin, enter the command:
The system asks for confirmation – press Y then Enter, and the system downloads and installs the phpMyAdmin software package. Step 3: Configure phpMyAdmin on UbuntuShortly the installation starts, the installer prompts to choose the web server to automatically configure. Select apache2 (use spacebar to choose), press Tab to navigate to <ok> and hit Enter. Next, the installer will notes that phpMyAdmin needs a database installed and configured before starting use. Select <Yes> and hit Enter. Note: If you’re an advanced user, you can manually configure the database, but doing so is outside the scope of this guide. Find more information on Shortly after, the installer asks to provide a password. The program creates a default user named "phpMyAdmin" and the password you type here works as an administrator password for this user. Type a strong password and hit Enter, then confirm the password and hit Enter again. Leaving the password field blank causes the system to generate a random password. Step 4: Enable the mbstring ExtensionMbstring is an extension for PHP. It helps email and .pdf files to work correctly, but it's not enabled by default. Enter the following in your terminal to enable mbstring:
Press Enter and allow the process to finish. Restart the Apache service to refresh the changes by entering the following in a terminal:
Step 5: Create a New MySQL Administrator AccountBy default, MySQL 5.7 and later in Ubuntu, authenticate a root user using auth_socket. This compares the socket username against the name specified in the MySQL user table and is a tightly-secured authentication method. However, this makes using phpMyAdmin difficult. It is possible to change the authentication type. However, a simpler method to avoid auth_socket is to create a new administrator account for MySQL. Log in to the MySQL server as follows:
This changes terminal prompt to show mysql>, indicating that you’re logged into the MySQL shell. Enter the following commands, replacing UserNamewith a username of your choice, and PassWordwith a strong password of your choice:
Once the operation completes, exit the MySQL shell by entering:
Step 6: Test phpMyAdminOpen up a browser window and enter localhost, your server’s IP address or domain name, followed by /phpMyAdmin:
The browser displays a screen welcoming you to phpMyAdmin, with a login field. Enter the username and password you created. The browser loads the phpMyAdmin dashboard. Being easy to use – and free – makes phpMyAdmin a target for hackers. Follow these steps to use Apache's built-in features to restrict access and secure phpMyAdmin directories. Enable .htaccessIn a terminal window, enter the following command to edit the phpmyadmin.conf file:
In the editor, find the section labeled
Just below these entries, add the following text:
Save the file and exit. Then, apply the changes by restarting Apache with the following terminal command:
Create .htaccess FileThe .htaccess file allows a more detailed configuration of the Apache web server. Enter the following in the terminal:
This creates a new file and opens it in a text editor. In the text editor, add the following lines:
Save the file and close. These commands configure .htaccess to use basic authentication, to secure restricted files only to valid users, and where to find a list of valid users. Setup .htaccess UsersThis step creates a username and password to access the phpMyAdmin directory. The process generates a prompt, forcing anyone trying to access the phpMyAdmin directory to enter a username and password. In the terminal window, enter the following:
Replace UserNamewith the actual username you want to use to access the phpMyAdmin directory. The system asks to enter and confirm a password. If you need to add additional users, use the same command without the
Test the LoginGo back to your browser window, and open The system activates a pop-up that asks for credentials, saying "Restricted files". Enter the username and password you created earlier. You should now see the phpMyAdmin login screen. Enter your credentials, and the system displays the phpMyAdmin user interface. Conclusion Great job, you now know how to install phpMyAdmin on Ubuntu. You should now be able to manage your MySQL database from the phpMyAdmin tool. This includes managing users, creating databases, and much more. PhpMyAdmin replaces the command line interface used in this guide with a more intuitive utility to simplify database management tasks. How do I know if phpMyAdmin is installed on Ubuntu?Get the name of the package with dpkg --list | grep phpmyadmin.. For list of file installed use this dpkg --listfiles <package_name step 1>. How do I install Apache php MySQL and phpMyAdmin on Ubuntu 22?Use the following steps to install and configure LAMP linux, apache, PHP, MySQL in ubuntu 22.04:. Step 1 – Update System Dependencies.. Step 2 – Install Apache.. Step 3 – Setup Firewall.. Step 4 – Check Apache Installation.. Step 5 – Install MySQL.. Step 6 – Secure MySQL.. Step 7 – Install PHP.. Step 8 – Configure PHP.. How do I fix phpMyAdmin access denied in Ubuntu?This will solve the problem “access denied for user ”@'localhost' to database phpmyadmin'”.. Step 1 – Login as Root user MySQL. ... . Step 2 – Restart Apache Server. ... . Step 3 – Test Root MySQL User For Access PHPMyadmin.. What version of phpMyAdmin do I have Ubuntu terminal?You can use simple cat and jq (operates on JSON files) commands to find phpmyadmin version from the package. json file located in the root directory. This example assumes that phpmyadmin is extracted to /home/user/phpmyadmin/ .
|