Last updated on: 2019-12-20 Show
Authored by: Paul Dolbear phpMyAdmin® is a free and open source administration tool for MySQL® and MariaDB®. As a portable web application written primarily in PHP, phpMyAdmin has become one of the most popular MySQL administration tools, especially for web hosting services. This article describes how to install and configure phpMyAdmin on your web server for CentOS® 7, Red Hat® Enterprise Linux® (RHEL) 7, and Ubuntu® 16.04 LTS. PrerequisitesBefore you can install phpMyAdmin, you must have the following installed on your server:
Check whether a web server is installedUse the commands in the following table to check whether a web server is installed:
Check whether PHP is installedUse the following command to check whether PHP is installed on CentOS or RHEL:
Use the following command to check whether PHP is installed on the Ubuntu operating system:
Install phpMyAdminUse the instructions in the following sections to install phpMyAdmin. CentOS and RHELInstall phpMyAdmin by using the following command:
The output should be similar to the following example:
The Ubuntu operating systemInstall phpMyAdmin by using the following command:
The output should be similar to the following example:
Press Y and then press Enter to continue to the configuration process. See the Configure phpMyAdmin on the Ubuntu operating system section for further instructions. Configure phpMyAdmin on CentOS and RHELAfter you have installed phpMyAdmin on your web server, use the instructions in the following sections to configure phpMyAdmin. Apache web serverYou first need to add the Internet Protocol (IP) address that you want to use to access phpMyAdmin to the /etc/phpMyAdmin/config.inc.php configuration file.
Set a URL alias (optional)The standard URL for a phpMyAdmin installation is https://ipaddress/phpMyAdmin, where ipaddress is the IP address that you added to the configuration file in the previous section. If you want to change the URL, you can set an alias.
Database configuration fileIf the MySQL or MariaDB database server that you want to use with phpMyAdmin is not located on the same server as your web server, you must edit the database configuration file to define the database server location. There are two configuration options:
Use the following steps to define the location of your database server:
To make the changes live, you must check the syntax of the web engine daemon and then gracefully restart or reload it. Check the syntax by using the following command:
If there are no errors in the configuration file, you should see Reload the Apache web server by using the following command: CentOS and RHEL 6
CentOS and RHEL 7
Check the status of the httpd service to ensure that it is functioning as expected by using the following command: CentOS and RHEL 6
CentOS and RHEL 7
You should now be able to view phpMyAdmin through a web browser, as shown in the following image: NGINX web serverOn NGINX, the phpMyAdmin package doesn’t come with a configuration file, so you have to create a server block to point at the phpMyAdmin configuration file.
To make the changes live, you must check the syntax of the web engine daemon and then gracefully restart or reload it. Use the following command to check the syntax:
If there are no errors in the configuration file, you should see Reload the NGINX web server by using the following command: CentOS and RHEL 6
CentOS and RHEL 7
Check the status of the NGINX service to ensure that it is functioning as expected by using the following command: CentOS and RHEL 6
CentOS and RHEL 7
You should now be able to view phpMyAdmin through a web browser, as shown in the following image: Configure phpMyAdmin on the Ubuntu operating systemUse the steps in the following sections to configure phpMyAdmin on the Ubuntu operating system. Apache web serverThe installation process adds the phpMyAdmin Apache configuration
file to the /etc/apache2/conf-enabled/ directory, where it is read automatically. The only thing you need to do is to enable the
After installing phpMyAdmin, the package configuration screen displays, as shown in the following image. Use the space bar to select apache2, press Tab to select Ok, and then press Enter. The installation process continues until another configuration screen displays that prompts you to confirm if you want to configure your database for
phpMyAdmin by using Select Yes, and then press Enter. You are prompted for your database administrator password. Input your password, press Tab to select Ok, and then press Enter. Next, enter a password for the phpMyAdmin application itself, press Tab to select Ok, and then press Enter. Confirm the password by selecting Ok, and then press Enter. After the installation process is complete, the phpMyAdmin configuration file is added to /etc/apache2/conf-enabled/phpmyadmin.conf. If this file doesn’t exist after the installation is complete, you can copy it from /etc/phpmyadmin/apache.conf to /etc/apache2/conf-enabled. If that file doesn’t exist, you must create a virtual host for phpMyAdmin with the following settings:
If at any time you need to reconfigure phpMyAdmin, you can use the following command:
Remote database configurationIf the database server that you want to manage with phpMyAdmin is remote, you must configure phpMyAdmin differently. The configuration files are located in the /etc/phpmyadmin directory. The main configuration file is /etc/phpmyadmin/config.inc.php, which contains the configuration options that apply globally to phpMyAdmin. To use phpMyAdmin to administer a MySQL database hosted on another server, open /etc/phpmyadmin/config.inc.php in a text editor and then edit the following line:
Note: Replace The other configuration file that you must edit is /etc/phpmyadmin/apache.conf. This file is linked symbolically to /etc/apache2/conf-available/phpmyadmin.conf. After it is enabled, it is used to configure Apache2 to serve the phpMyAdmin site. The file contains directives for loading PHP, directory permissions, and so on. Run the following command to enable the configuration file, and then reload the service:
Now that phpMyAdmin is installed on the client computer, connect to the remote server where the MySQL or MariaDB database is installed. Open the file /etc/mysql/mysql.conf.d/mysql.cnf and edit the following line:
Replace Run the following command to allow the root user to access the server from the client computer:
Replace the IP address with the address of the remote server, and After you edit the configuration settings, open a browser and navigate to https://clientPC/phpmyadmin, using the client computer IP address or host name. You should be able to log on remotely to the server from the client phpMyAdmin web portal. Reload the web serverTo make the changes to the configuration files live, you must first check the syntax of the file and then gracefully restart or reload the web server. Use the following command to check the syntax of the configuration files:
Then reload the Apache web server by running the following command:
Check the status of the service to ensure that it is functioning as expected by running the following command:
You should now be able to view phpMyAdmin through a web browser, as shown in the following image: NGINX web serverAfter installing phpMyAdmin, the package configuration screen displays, as shown in the following image: Use the space bar to select apache2, press Tab to select Ok, and then press Enter. The installation process continues until another configuration screen displays that prompts you to confirm if you want to configure your database for
phpMyAdmin by using Select Yes, and then press Enter. You are prompted for your database administrator password. Input your password, press Tab to select Ok, and then press Enter. Next, enter a password for the phpMyAdmin application itself, press Tab to select Ok, and then press Enter. Confirm the password by selecting Ok, and then press Enter. After the installation process is complete, you must create the phpMyAdmin configuration file here: /etc/nginx/sites-enabled/phpmyadmin.conf. Enter the following information in the file and then save it:
Your phpMyAdmin files are located in the /usr/share/phpmyadmin/ directory. The configuration above tells NGINX that if visitors enter https://ip_address/phpmyadmin in the browser address bar, it should find the index.php file in the /usr/share/phpmyadmin/ directory and display it. Reload the web serverTo make the changes to the configuration files live, you must first check the syntax of the file and then gracefully restart or reload the web server. Use the following command to check the syntax of the configuration files:
Then reload the Apache web server by running the following command: RHEL and CentOS 6
RHEl and CentOS 7
Check the status of the service to ensure that it is functioning as expected by running the following command: RHEL and CentOS 6
RHEL and CentOS 7
You should now be able to view phpMyAdmin through a web browser, as shown in the following image: Configure additional security (optional)
Use the steps in the following sections to set up basic authentication on a web server running phpMyAdmin. Apache web serverBy default, Apache does not allow the use of Open the Apache configuration file in a text editor and find the section that begins with For RHEL and CentOS, the configuration file is /etc/httpd/conf/httpd.conf. For the Ubuntu operating system, the configuration file is /etc/apache2/conf/httpd.conf. Change the line from Note: If this line reads Save and close the file. The
After you create a user, run the following command to see the username and password in the /etc/phpMyAdmin/.phpmyadmin-htpasswd file:
The output should be similar to the following example:
Now you need to allow the
Finally, you must uncomment the following lines from the phpMyAdmin configuration files:
NGINX web serverThe
After you create a user, run the following command to see the username and password in the /etc/nginx/.pma_pass file:
The output should be similar to the following example:
Now you need to allow the
Finally, you must uncomment the following lines from the phpMyAdmin configuration files:
How do I access MySQL in phpMyAdmin?To connect to a MySQL database, please follow these steps:. Open a browser window and go to www.HostMySite.com.. Click on Control Panel Login.. Log into the Control Panel as one of the following: ... . Click on MySQL Databases.. Select the database from the list and clickphpMyAdmin.. How do I know if phpMyAdmin is installed?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 start MySQL command line in phpMyAdmin?use mysql command “mysql -uroot -p” to login into mysql, here -u for taking user name of mysql and -p for password. to create database in mysql run command create database learn_php, here learn_php is database name and create database is mysql command. for use of created database run command use learn_php.
Can I use phpMyAdmin with MySQL?phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web. phpMyAdmin supports a wide range of operations on MySQL and MariaDB.
|