Any web developer knows that almost every site needs a database. It allows you to store information, manage it and receive it at the right time. So that all of the above can be used in a more convenient form, a group of enthusiasts decided to create a product that combines convenience and functionality when working with a DBMS. Its name is phpMyAdmin. As a rule, it is already available on many hosting sites. Therefore, the article will focus on how to install and configure phpMyAdmin on the local server.
Training
Since phpMyAdmin itself is written in php, for its work you will need to install the whole set of necessary software - Apache, PHP, MySQL.
Each component can be installed manually individually, but everything can be done right away. For Linux there is a bunch of LAMP, for Windows - "Denver" or OpenServer. Installing all the software and configuring it separately will allow you to study the composition and structure of the entire server. If time does not allow to deal with the internal structure, it is easier and more convenient to immediately put the assembly.
Configuring PhpMyAdmin in Ubuntu
The package is available in the standard Ubuntu repositories, so just type the command in the terminal:
sudo apt-get install phpMyAdmin.
In the process, you will be prompted to go through the phpMyAdmin configuration steps. At the first, you need to select the web server that you plan to use to run. In this case, it is apache2.
The next window will prompt you to configure the database for phpMyAdmin. It is worth agreeing. The system will ask for a password for MySQL. And then for phpMyAdmin.
After that, in the folder / etc / apache2 / conf-enabled / a configuration file will appear.
It remains to install a couple of parts and activate them. You can use the commands:
sudo apt-get install php-mbstring php-gettext.
And their launch is performed like this:
sudo phpenmod mcrypt;
sudo phpenmod mbstring.
After that, you will need to restart the web server. This is done using the command:
sudo systemctl restart apache2.
In theory, everything is ready and you can begin to work.
Launch and configuration
To get into the bowels of phpMyAdmin settings you need to open any browser and type in the address bar:
created domain / phpmyadmin.
The application will ask for a password to enter. It was created during the installation phase. After entering, the user will see an interface with many elements and settings.
Control Panel
The application interface is divided into logical blocks, united by a general principle.
On the left is a panel for a quick transition between databases and tables. Here you can create a new instance of this or that format.
The top menu contains items for navigating to the table settings, as well as additional functionality:
- Databases Almost duplicates the menu on the left, that is, it contains a list of available databases;
- SQL A very interesting point for those who know how to correctly compose queries, and actively use them. You can manually select, delete, sort, and other SQL functions;
- condition . The current position in the bases. Their total volume, traffic, the amount of received and sent data;
- user accounts . All stored data about users, indicating their privileges, addresses and passwords;
- export and import . Very convenient functions for exchanging between the base and other software. For example, to update the site manually, if the need arose. In addition, it is a very convenient tool for creating a backup of important data, if this is not automatically possible;
- settings . A lot of different parameters, one way or another related to the work of phpMyAdmin, databases, requests and much more;
- replication . Communication with other servers for simultaneous changes on replicas - that is, repeated instances of the current database server;
- variables . As the name implies, the section contains values โโfor the internal needs of the server and system. Unnecessarily, as a rule, they are not used;
- encodings . Shows all the font display options available in the system;
- information about the types of data storage used in phpMyAdmin;
- extensions . The list of phpMyAdmin add-ons that increase the functionality of the system.
General settings right in the middle allow you to change the password or set the used text encoding.
Display options will help to change the language, theme, font size and other settings for the appearance of the system.
On the right is an information panel with information about the database server and the web server, as well as several links for help on phpMyAdmin.
Unfortunately, attackers often use the application to gain unauthorized access, so you need to know how to protect yourself from this.
Security
The very first thing to do is use the Apache htaccess web server files. First you need to tell apache that a special file will be used to configure phpMyAdmin.
To do this, configure the configuration file located at /etc/apache2/conf-available/phpmyadmin.conf.
You need to add the special AllowOverride All directive. After changing and saving the file, you need to restart the web server again.
Now, to configure phpMyAdmin, you will need the file itself, in which the access rules to the control panel will be defined. It should be called .htaccess and placed on the path / usr / share / phpmyadmin.
It indicates the following parameters:
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user.
It. a set of keywords will allow you to do the following:
- The first line is responsible for the nature of the authorization. The โbasicโ parameter means that you can enter by login and password.
- The second determines which text will be displayed instead of the greeting.
- The third line indicates the file in which the password will be stored.
- The fourth tells the system that only authenticated users can get here.
After creating the file, you need to save it. Do not forget to do it.
Password
Having to create a password file when setting up phpMyAdmin will have to tinker a bit.
First you need to install the htpasswd utility. It is available in the Ubuntu repositories, so just execute the command in the terminal:
sudo apt-get install apache2-utils.
Now all the same in the terminal you need to type:
sudo htpasswd -c /etc/phpmyadmin/.htpasswd username.
She will create a new user and offer to specify a password for him.
Access is now secure. When you try to enter the phpMyAdmin admin panel of the user, an additional window will open for obtaining viewing rights and changing settings.
CentOS
Setting up phpMyAdmin on CentOS is actually not much different. The algorithm of actions will be almost the same. Unless the installation command is a little different:
yum install -y phpmyadmin
All further settings and manipulations are relevant for both Ubuntu and CentOS.
Windows environment
There are several ready-made solutions for creating a server with an existing set of technologies for the Windows operating system. For example, OpenServer. It already contains the installed phpMyAdmin on board. You can find it in the serverโs context menu, in the "Advanced" item.
MySQL and phpMyAdmin are configured in OpenServer using various ready-made menus and windows, which is undoubtedly more convenient than manually entering commands.
Recommendations
Before concluding, we can talk about several commonly encountered errors and subtleties of configuration. Here are the basic tips for setting up phpMyAdmin, Apache, and MySQL:
- to avoid server crashes, you should use the latest software versions;
- most likely phpMyAdmin is already installed on the hosting, but its security can still be configured through htaccess files;
- it is worth paying attention to the choice of password. Often, its restoration takes much longer than a thoughtful approach to its creation;
- Using ready-made assemblies allows you to implement a quick server deployment with everything you need, but it does not always give you the flexibility to configure it and understand the intricacies of work.
Finally
PhpMyAdmin is used on many services and sites on the Internet. This can be explained by the ease of configuration and access to the database. As well as the presence of a large number of additional features and capabilities. The project is constantly evolving and adapting to new solutions and technologies.