
phpMyAdmin is an open-source web-based tool used to manage MySQL databases. If you install phpMyAdmin on Ubuntu 24.04, you’ll gain access to a user-friendly interface for creating, modifying, and deleting databases, tables, and fields. It also allows you to manage users, import and export databases, and execute SQL statements. With phpMyAdmin, you can easily run SQL queries on a database server without needing to use the command-line interface (CLI).
This article explains how to install phpMyAdmin on Ubuntu 24.04. You will create MySQL databases, and access the phpMyAdmin interface to manage users and databases.
Before you begin, you need to:
Follow the steps below to set up the MySQL database server and create a sample database to use with phpMyAdmin.
Update the APT package information index.
Install MySQL server if it's not installed.
Log in to the MySQL database server.
Create a sample my_company database.
Create a new company_admin MySQL user with a strong password. Replace your_password with a strong password.
Grant the company_admin user full privileges to the my_company database.
Flush the MySQL privileges table to apply the user changes.
Exit the MySQL console.
phpMyAdmin is available in the default package repositories on Ubuntu 24.04. Follow the steps below to install phpMyAdmin using the APT package manager.
Update the APT package information index.
Install PHP and all required PHP extensions.
Install phpMyAdmin.
Select the following phpMyAdmin configuration options when prompted:
apache2 and press Enter to save your selection.Yes selected and press Enter to configure the MySQL database.Verify that the phpMyAdmin installation is successful.
Output:
phpMyAdmin includes a default Apache virtual host configuration file used to serve the /phpmyadmin endpoint using your server's IP or domain. Follow the steps below to verify that the phpMyAdmin configuration is enabled and start the Apache web server.
Enable the phpMyAdmin virtual host configuration using the a2enconf command.
Output:
Restart Apache to apply the configuration changes.
View the Apache web server status and verify that it's running.
Output:
View the UFW status and verify that the firewall is active.
Run the following command to install UFW and allow SSH connections if it's unavailable.
Allow the Apache Full profile through the firewall to enable HTTP and HTTPS connections on the server.
Reload UFW to apply the firewall configuration changes.
Follow the steps below to access phpMyAdmin and manage the sample MySQL database you created earlier.
Access the /phpmyadmin endpoint using your server's IP address or domain name in a web browser such as Chrome.
Log in to phpMyAdmin using the sample company_admin MySQL user account credentials you created earlier.
Verify that the phpMyAdmin interface loads correctly in your web browser.
Click the my_company database on the left navigation menu to manage it.
Avoid logging in to phpMyAdmin using the MySQL root user account as this poses significant risks, including accidental deletions, modifications, and security vulnerabilities. Instead, always create a dedicated user account with the necessary permissions for a specific database(s).
This ensures a more secure and controlled environment, reducing the risk of unintentional actions that could compromise your data and server incase a malicious user gets access to your database account.
Basic authentication prompts users for a password to access the phpMyAdmin interface. Follow the steps below to secure the phpMyAdmin endpoint with basic authentication to prompt users for a password to manage databases.
Create a new .htpasswd file with a new username and password. Replace your_username with your desired username such as smith and enter your desired password when prompted.
Open the Apache virtual host configuration for phpMyAdmin.
Add the following AllowOverride All directive within the /usr/share/phpmyadmin directory block.
Your modified directory block should be similar to the one below.
Create a new .htaccess file in the /usr/share/phpmyadmin/ directory.
Add the following configurations to the .htaccess file.
In the above .htaccess file:
The above .htaccess configuration enables basic authentication on the phpMyAdmin endpoint. Within the configuration:
AuthType Basic: Specifies the authentication type as Basic.AuthName "Restricted Access to PhpMyAdmin": Sets a custom message to display in the sign-in prompt.AuthUserFile /etc/phpmyadmin/.htpasswd: Sets /etc/phpmyadmin/.htpasswd as the basic authentication file that includes the allowed users and encrypted passwords.Require valid-user: Requests a valid user to access the phpMyAdmin interface.Restart Apache to apply the configuration changes.
Access phpMyAdmin again and verify that you are prompted for a user password to log in.
Log in to phpMyAdmin using your MySQL user credentials to manage databases on your server.
Follow the sections below to troubleshoot your phpMyAdmin installation in case of any common errors.
Verify that the MySQL database server is running.
Verify your MySQL username and password.
View the phpMyAdmin configuration file and find any possible errors.
View Apache error logs for detailed information.
Install all required PHP extensions.
Log in to the MySQL server.
Create a new MySQL user.
Grant the user full privileges to your target database.
Flush the MySQL privileges table to apply changes.
Exit the MySQL database console and access phpMyAdmin again.
You have installed phpMyAdmin on Ubuntu 24.04. phpMyAdmin provides a convenient web-based interface for managing your MySQL databases. You can now use phpMyAdmin to perform database administration tasks to manage databases, insert records, and query tables to generate reports. For more information and configuration options, visit the phpMyAdmin documentation.
0 Comments
Be the first to comment and share your perspective with the community.