This tutorial shows you how to install phpMyAdmin from Apache, MariaDB, PHP7.4 (LAMP stack) to Ubuntu 20.04 LTS. phpMyAdmin is a free and open source web database management tool written in PHP. It offers a web GUI for managing a MySQL or MariaDB database. We will also learn how to enable two-factor authentication on phpMyAdmin.
phpMyAdmin allows:
- Searching databases and tables ;
- Creating, copying, renaming, modifying and deleting databases ;
- to create, copy, rename, modify and delete tables;
- to perform the table service;
- to add, modify and delete fields;
- to execute any SQL expression, even multiple questions; Continued AWS Cloud support.
- to create, modify and reduce the indexes;
- Upload text files in tables ;
- Create and read dumps from tables or databases ;
- Export data to SQL, CSV, XML, Word, Excel, PDF and LaTeX formats
- to manage multiple servers;
- Manage MySQL users and permissions ;
- Check server settings and runtime information with configuration requests ;
- Check the integrity of the links in the MyISAM tables;
- Automatically create complex queries with the Query-by-example (QBE) function
- Connecting the required arrays ;
- create a PDF file of the layout of the database;
- to perform a global search of a database or subset thereof;
- convert stored data into any format using a number of predefined functions, such as displaying BLOB data as an image or a download link
- for the management of InnoDB tables and foreign keys ;
Requirements
To follow these instructions, the Ubuntu 20.04 operating system must be running on a local computer or a remote server.
If you are looking for a VPS (Virtual Private Server), you can create a Vultr account via my referral link to get $50 free credit (for new users only). And if you need to configure phpMyAdmin with a domain name, I recommend you buy domain names from NameCheap because the price is low and they offer Whois privacy for free.
It is assumed that the LAMP stack is already installed on Ubuntu 20.04. Otherwise, read the following manual.
Let’s start installing phpMyAdmin.
Step 1: Downloading and installing phpMyAdmin on Ubuntu 20.04
phpMyAdmin is part of the Ubuntu 20.04 software repository, so we can easily install it with the command below.
sudo apt update
sudo apt installation by phpmyadmin
The above command installs all necessary dependencies, including PHP7 extensions. During installation, the program will ask you to select a web server to configure. Press the space bar to select apache2. (An asterisk indicates that the item is selected). Then press Tab and Enter to confirm your choice.
On the next screen, select Yes to configure the database for phpMyAdmin with dbconfig-common.
Then set a password for the user phpmyadmin in MariaDB/MySQL.
After this step a new database is created with the name phpmyadmin and the user of the phpmyadmin database has the necessary authorizations to manage this database. If you are as interested as I am, you can login to MariaDB and see what privileges phpmyadmin users have.
You can use the following command to connect to the MariaDB server.
sudo mysql -u root
Then check the rights of the user phpmyadmin.
See grants for [email security];
A way out:
As you can see, a phpmyadmin user has full rights in the phpmyadmin database. Now, you can get away with it:
A way out;
Step 2: Access to phpMyAdmin from subdirectory
When installing phpMyAdmin, the configuration file is stored in /etc/apache2/conf-enabled/phpmyadmin.conf, which gives us access to phpMyAdmin via a subdirectory. If you have other web applications such as WordPress installed on the same Ubuntu 20.04 server, simply add /phpmyadmin after your domain name in the address bar of your browser.
example.com/phpmyadmin
If phpMyAdmin is installed on your local Ubuntu computer, you can access the phpMyAdmin web interface by entering the following text in your browser’s address bar
Local
If the connection is rejected or not established, there may be a firewall that prevents HTTP requests. If you are using the iptables firewall, you will need to execute the following commands to open TCP ports 80 and 443.
sudo iptables – INPUT -p tcp –dport 80 -j APPLICATION
sudo iptables -I INPUT -p tcp –dport 443 -j APPLICATION
If you are using a UFW firewall, run this command to open TCP ports 80 and 443.
allows sudo ufw 80 443/tcp
You can now use your MariaDB/MySQL username and password to login to phpMyAdmin. If you cannot log in as root, go to step 5 to solve this problem.
Step 3: Access to phpMyAdmin from subdomain
If your Ubuntu 20.04 server does not have another virtual Apache host, you can use the subdomain to access the phpMyAdmin web interface. Enables HTTPS for traffic encryption.
First we need to create a virtual Apache host for phpMyAdmin. The existing phpMyAdmin configuration fragment can be used as a template. Let’s copy it to a new file.
sudo cp /etc/apache2/conf-enabled/phpmyadmin.conf /etc/apache2/sites-available/phpmyadmin.conf
Then edit the new file with a command line text editor such as Nano.
sudo nano /etc/apache2/sites-available/phpmyadmin.conf
There are no tags in this file, so we need to add the following lines to the beginning of this file. Replace pma.example.com with your favorite subdomain for phpMyAdmin. Don’t forget to create a DNS-A-record for this subdomain.
Server name pma.example.com
Reboot document /usr/share/phpmyadmin
Error Log ${APACHE_LOG_DIR}/pma.error.log
User Log ${APACHE_LOG_DIR}/pma.access.logmerged
Add the following line at the end of this file to the
Save the file and close it. (To save the file in the NANO editor, press Ctrl+O and then press Enter to confirm. Press Ctrl+X to exit) Then enable this virtual host.
a2enzit phpmyadmin.conf
Restart the Apache web server to make this change effective.
sudo systemctl restart apache2
You should now be able to access the phpMyAdmin web interface via
pma.example.com
Before entering the user’s identification data in the authorization form, activate the HTTPS.
Step 4: Enabling HTTPS to phpMyAdmin with Apache
To secure the phpMyadmin web interface, we can install a free TLS certificate Cryptons TLS. Run the following command to install the Let’s Encrypt client (certbot) from the Ubuntu 20.04 software repository
install sudo apt certbot python3-certbot-apache
Python3-certbot-apache is an Apache plugin for Certbot. Now execute the following command to obtain and install the TLS certificate.
sudo certbot –apache –agree-tos –redirect –hsts –staple-ocsp –must stack -d pma.example.com –email [protected by email].
True:
- -Apache: Use an Apache authenticator and installer.
- -agri-tos: Okay, let’s encrypt the terms of use.
- -directly: Implement HTTPS by adding constant 301 bypass.
- -…. Add a Strict Transport Security header to every HTTP response.
- -stack-okr: Do not allow OCSP.
- -There’s gotta be a stalker. -There’s gotta be a stalker: Adds OCSP must not add renewal to the certificate
- the -d flag is accompanied by a list of domain names separated by commas. You can add up to 100 domain names.
- -E-mail: Email used to store and restore contacts.
You will be asked if you want to receive e-mails from the EFF (Electronic Frontier Foundation). After selecting Y or N, your TLS certificate will be automatically received and configured for you as indicated in the following message.
Step 5: Troubleshooting PhpMyAdmin Connection error
When you try to connect to phpMyAdmin with the MariaDB root, you may get the following error message.
#1698 – Access denied to user ‘root @’localhost
or
mysqli_real_connect() : (HY000/1698): Access is denied to the root user ‘@’localhost’.
If you login with a phpmyadmin user, you will not see the error above. However, a custom phpmyadmin can only be used to manage the phpmyadmin database. The reason for this error is that the root user of MariDB is authenticated by default through the unix_socket plugin, and not through the mysql_native_password plugin. To solve this problem, we can create another admin user and give him all the privileges.
Connect to the MariaDB server via the command line.
sudo mysql -u root
Create an administrator user with password authentication.
Create a user [protected via e-mail] that is identified with your favorite password;
Give all privileges for all databases.
Give full privileges for *.* for [email security] with Deploy ;
Privilege and flash output ;
to relinquish those privileges;
A way out;
You can now login to phpMyAmin with administrator rights and manage all databases.
Packaging
I hope this guide helped you install phpMyAdmin from LAMP in Ubuntu 20.04. As always, if you find this message useful, subscribe to our free newsletter for more tips and tricks. Take care of yourself.
Evaluate this training manual.
On second thought: 0 Average : 0]