Hello BitCucos! In this tutorial we going to explain how to install the MySQL administrator PhpMyAdmin for your web server at localhost/phpmyadmin. This platform is easier for manage your MySQL (or MariaDB) databases through a graphical interface, implemented at server level using the PHP language.
PhpMyAdmin logo: Image license: https://www.phpmyadmin.net/license/
The content of this tutorial is not exactly an introduction to MySQL, it is a practical way. We show you how to install PhpMyAdmin in this url: localhost/phpmyadmin, which is the default path to access your MySQL (or MariaDB) Database manager once you have implemented the user interface, and you can access it from your favorite browser.
We will show you how to install PhpMyAdmin server from scratch to access your MySQL databases in the simplest way.
Prerequisites to install PhpMyAdmin
Before proceeding with the install of PhpMyAdmin, we need to install MySQL (or MariaDB), PHP and a web server before launch the platform that will be located at this url: localhost/phpmyadmin.
In this example, we will use a fresh installation of a LAMP server, that is, Linux, Apache, MySQL and Php. However, you can also use a WAMP server (Windows, Apache, MySQL and Php) or WIMP server (Windows, IIS, MySQL and Php). So it doesn’t matter so much the operating system and the web server used, only the two technologies required by PhpMyAdmin to work are MySQL (or MariaDB) and Php.
Install a LAMP Server
To install Linux (any distribution) is beyond the scope of this tutorial, however its installation is very simple. If you are a beginner, we recommend using a distribution based on Debian or RedHat that have a graphical interface. For example: Ubuntu (https://ubuntu.com/
Install Apache (httpd)
Apache is the most popular Open Source web server for Linux environments. It is a complete web server to handle all types of web requests, such as GET, POST, PUT, PATCH, DELETE, etc.
We are going to show you the simplest configuration for Apache. Their website is here: https://httpd.apache.org/. To install Apache in Fedora, you can use the yum command in superuser mode (if we are using root or superuser, you can omit the word “sudo”)
sudo yum install httpd
To launch the apache daemon, we simply start the service like so:
sudo systemctl start httpd.service
sudo systemctl start httpd
Then we enable that the service to start on boot:
sudo systemctl enable httpd
If you are using the default configuration and you do not install any other web server, it should be loading using port 80. You could check that the web server is already enabled searching in your browser: http://localhost or simply localhost. If it works correctly, a screen similar to this will be displayed:
Install MariaDB (MySQL)
MariaDB is an Open Source version that follows the exact syntax as MySQL, we can consider MariaDB as a clone. This is the Database manager that will allow us to use the tables that we will create.
To install MariaDB, we use the following command in superuser mode:
sudo yum install mariadb-server mariadb
Once the installation is finished, we proceed to start the service with the following command:
sudo systemctl start mariadb
To provide a secure configuration to our MariaDB database that we just installed, we use the following command:
With the previous command, we delete some security problems derived from the default configuration of MariaDB. The system requests some information for the initial configuration, and it consists of a password, which we recommend a unique password for MariaDB.
Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorization. New password: [enter your new password] Re-enter new password: [confirm your new password] Password updated successfully! Reloading privilege tables.. ... Success!
The other values can be set by default without problems, so there is no problem pressing Enter to another otions. Finally we enable MariaDB to start as a service when booting the computer:
sudo systemctl enable mariadb.service
Now we proceed to install PHP. Php is a programming language that is responsible for run code at server level to directly interacts with the web server, with the possibility of using some Linux modules.
To install Php and the module that works with MariaDB or MySQL, we use the following command in superuser mode:
sudo yum install php php-mysql
At the end of the installation, we proceed to restart our web server to load the new configuration (the php.ini file):
sudo systemctl restart httpd
Once our web server is running, able to read and respond the requests from localhost. We proceed to install PhpMyAdmin. As a first step, we go to the PhpMyAdmin website and download the installer here.
Once the installer is downloaded, we unzip it. To unzip it, we run the following command (the latest version changes, always check what is the latest version on the phpMyAdmin website before downloading)
And the content should be placed in the public directory of your website. Normally should be placed here: /var/www/public_html/ or /var/www/html/ directories, which are the default directories that are configured on the web server, so you can access PhpMyAdmin searching this url: localhost/phpmyadmin.
Install PhpMyAdmin on Fedora, RedHat or CentOS
You could use yum to install the package on your computer. It will be stored in your default directory. You must install the REPEL repository before to install PhpMyAdmin
Now we install the last version of EPEL repository, in this example we use version 6.8:
Once the EPEL version is downloaded, you must install the downloaded rpm:
sudo rpm -ivh epel-release *
And after the install of EPEL repository, you can install phpMyAdmin in a very simple way using the yum command:
sudo yum install phpmyadmin
Finally we restart the web server using the command:
sudo systemctl restart httpd
Install PhpMyAdmin on Ubuntu or Debian
Installing phpMyAdmin on Debian-like distributions, for example Ubuntu, requires using the apt-get command as follows:
sudo apt-get install phpmyadmin php-mbstring php-gettext
Once the installation of phpMyAdmin is finished, we restart the Apache web server using the Ubuntu service command:
service apache2 restart
Start phpMyAdmin (localhost/phpmyadmin)
Finally, we have configured our LAMP server, downloaded and installed phpMyAdmin. To verify that the installation has been successful, it is sufficient to open localhost/phpmyadmin in the web browser. If the installation has been successful, PhpMyAdmin Login window will appear:
If you see the PhpMyAdmin Login window in the url localhost/phpmyadmin, you are great!. Now it’s time to configure and customize your PhpMyAdmin configuration: Install php modules, modify the url in Apache to access remotely, add your MySQL users, tables, permissions, roles, etc. Anyway, you have only reached the beginning of the mountain. Welcome to MySQL!