Installing phpmyadmin ubuntu server 14.04. Installing and configuring phpMyAdmin on Ubuntu, Linux. Creating a new database

Phpmyadmin is one of the most popular tools for managing mysql databases through a web interface. It is written in PHP and JavaScript and with it you can manage a local or remote database server.

Using PhpMyAdmin we can create, delete, rename, edit databases, tables, fields, as well as manage users, export, import records and execute any SQL commands. Currently supported database servers are MariaDB, MySQL and Drizzle. In this article we will look at how to install PhpMyAdmin Ubuntu 16.04 on an Apache or Nginx web server.

Installing PhpMyAdmin on Ubuntu 16.04

The phpmyadmin utility is available in the official Ubuntu repositories. So you can install it from there very easily. To do this, first update the list of repositories:

Then install the program itself:

sudo apt install phpmyadmin

The official repositories contain an older version, so if you want to install the latest version of phpmyadmin ubuntu, you need to use the PPA:

sudo add-apt-repository ppa:nijel/phpmyadmin
$ sudo apt-get update
$ sudo apt install phpmyadmin

During installation it will be necessary to select the web server with which we will install phpmyadmin, select Apache using spacebar and press OK:

Settings for Nginx will have to be specified manually and we will look at them a little later. Next you need to set a password for the PhpMyAdmin database, click Yes:

Then enter the required password twice. You are unlikely to need it in the future, so you can choose something complex:

You may have to include several php modules and the apache configuration file to make it work:

sudo phpenmod mcrypt
$sudo phpenmod mbstring

Then include the Apache configuration file:

sudo a2enconf phpmyadmin

Installing phpmyadmin nginx ubuntu is done by adding the following section to the /etc/nginx/nginx.conf file, we assume that nginx is running through php-fpm:

sudo vi /etc/nginx/nginx.conf

server(
listen 80;
server_name phpmyadmin;
access_log /var/log/phpmyadmin.access_log;
error_log /var/log/phpmyadmin.error_log;

location ^~ /phpmyadmin/ (
alias /usr/share/phpMyAdmin/;
index index.php;
location ~ /phpmyadmin(/.*\.php) (
include fastcgi.conf;
fastcgi_param SERVER_NAME localhost;
fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin$1;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
}

Save and restart your web server:

sudo systemctl restart apache2

sudo systemctl restart nginx

Now everything should definitely work. Open your browser and type http://localhost/phpmyadmin in the address bar:

Enter your username and password and then you can do whatever you need with the databases.

PhpMyAdmin protection

Installation of phpmyadmn Ubuntu 16.04 is complete. But this program gives full control over the database, so we need to ensure its maximum security. Let's make access to Phpmyadmin using a password. To configure Apache, create a file /usr/share/phpmyadmin/.htaccess with the following content:

sudo vi /usr/share/phpmyadmin/.htaccess

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

This is what these lines mean:

  • AuthType Basic- this line sets the authentication type, we indicate that we will use a password;
  • AuthName- set the message that will be seen;
  • AuthUserFile- a file with data that will be used for authentication;
  • Require- a necessary condition for authentication.

sudo htpasswd -c /etc/phpmyadmin/.htpasswd user

You can add multiple users, but do not use the -c option to do this:

sudo htpasswd /etc/phpmyadmin/.htpasswd user

Now, when you try to open the phpmyadmin address, the system will ask for a password. Only users who enter the password will be able to access the phpmyadmin login interface.

conclusions

In this article, we looked at how to install phpmyadmin Ubuntu 16.04. As you can see, everything is very simple, and it only takes a little time to figure it out. If you have any questions, ask in the comments!

— local server for Linux. Unfortunately, the phpMyAdmin database administration tool is not included in the LAMP toolkit and must be installed separately. This article will teach you how to use phpMyAdmin.

Installing phpMyAdmin on Ubuntu

Very often, phpMyAdmin (PMA) is found on paid hosting services and is used to create and administer website databases. There is no need to install it on paid hosting - everything is already done there before you. Most often, you will encounter installing PMA on your computer to administer local server databases. As an example I'll look at installing phpMyAdmin on Ubuntu is one of the most popular Linux distributions.

Open a terminal and enter the following command:

sudo apt-get install phpmyadmin

After that, enter the administrator password and agree to continue with the installation.

Select a web server that will be automatically configured to run PMA. In our case it is apache2.

Agree to configure the database using dbconfig-common.

Enter the MySQL administrator password.

Set a password to register PMA on the database server and then confirm it. After installation is complete, phpMyAdmin will be available at http://localhost/phpmyadmin.

phpMyAdmin is not working

If you go to this address and see an error page, you can do the following.

  • enter the command in the terminal:
    sudo ln - s / etc/ phpmyadmin/ apache. conf /etc/apache2/conf. d
  • restart the apache server using the command:
    sudo /etc/init. d/ apache2 restart
  • Revisit http://localhost/phpmyadmin and you should now see the phpMyAdmin admin login page.

The user will be root and the password you set during installation.

Creating a new database

After authentication, we get to the PMA start page, where you can select the interface language, if you have not done so before, view information about the MySQL database management system and the web server used. The left column shows all available databases.

What will come in handy first? Of course, the ability to create a database for a future website. To do this, go to the Databases tab.

Just enter the name of the new database and click on the “Create” button - phpMyAdmin will do the rest automatically.

A message indicating the successful creation of the database will appear and it will be added to the list below.

Adding a new database user

Having created a new database, you also need to add a user who could use it.

To do this, click on the inscription “Check privileges”. You will be redirected to the “Users with access rights to the database” page, on which you should click on “Add a new user”.

In the “Account Information” section, enter the username (in English letters), host (on the local server - localhost) and password.

Just below you need to set privileges for the new user. On a local server, you can tick all the boxes without hesitation. After this, click on the “OK” button at the very bottom and a new user will be created.

Import and export of databases

To create a backup copy of the database, use the “Export” section.

In the case of the “fast” export method, backups of all available databases will be created at once in the format selected below.

, | |

For correct operation of many web projects, database management systems (DBMS), for example, MySQL, are needed. However, interacting with the system exclusively using the MySQL command line is not always convenient.

With phpMyAdmin, users can manage the MySQL system through a web interface. This guide provides step-by-step instructions for installing and securing the phpMyAdmin web interface.

Requirements

To follow this guide you will need:

  • A non-root user account with sudo privileges (you can find out how to create such a user in the article “”);
  • Pre-installed group of LAMP programs (Linux, Apache, MySQL, PHP); For instructions on installing LAMP stack on an Ubuntu 14.04 server, read.

Once you have completed the prerequisites, you can begin installing phpMyAdmin.

1: Install phpMyAdmin

phpMyAdmin can be quickly installed from the standard Ubuntu repository.

To do this, update the list of system packages, and then download and install the files using the apt package manager:

sudo apt-get update
sudo apt-get install phpmyadmin

In order to set up the installation, you need to answer several questions.

  • Select apache2 as the server.

Note: If you do not press Spacebar when selecting a server, the installer will not be able to move the necessary files during installation. To select Apache, press Spacebar, Tab, and then Enter.

  • When asked if you need to use dbconfig-common to configure the database, answer yes.
  • Enter the DBMS administrator password.
  • You will now be asked to select and confirm a password for the phpMyAdmin application.

During installation, the phpMyAdmin configuration file is added to the /etc/apache2/conf-enabled/ directory, where it is read automatically.

All that remains is to explicitly enable the php5-mcrypt extension, which can be done using:

sudo php5enmod mcrypt

Then restart Apache to update the configurations:

sudo service apache2 restart

Ready! To open the interface, visit in your browser:

http://domain_or_IP/phpmyadmin

To log into phpMyAdmin, use the root username and password you created during installation. The user interface will appear on the screen.

2: Protect phpMyAdmin

As you can see, installing and running phpMyAdmin is a fairly simple process. However, do not forget that due to its ubiquity, PhpMyAdmin is often subject to attacks by cybercriminals. At this stage, it is necessary to provide the interface with a sufficient level of protection to prevent unauthorized use.

One of the easiest ways to secure phpMyAdmin is to host a security gateway. This is done using special Apache files called .htaccess.

Activating .htaccess override

First you need to activate the .htaccess file by editing the Apache configuration file.

So, open the Apache configuration file:

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

To section you need to add the AllowOverride All parameter:


Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
. . .

After entering the required line, save and close the file.

To update the settings, restart the web server:

sudo service apache2 restart

Creating the .htaccess file

The application now supports .htaccess files; you just need to create such a file.

For correct operation, you must create this file in the application directory. So, to create the desired file and open it in a text editor with root privileges, type:

sudo nano /usr/share/phpmyadmin/.htaccess

You need to add the following code to this file:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

Let's look at these lines in more detail:

  • AuthTypeBasic specifies the authorization type; in this case, password authentication is used using a password file.
  • AuthName contains the text of the authentication dialog box message. To prevent unauthorized users from obtaining additional information about a closed application, this message should not contain details, but only general information (for example, “Restricted Files”, “Restricted Stuff”, “Private Zone”, etc.).
  • AuthUserFile specifies the location of the password file that will be used for authorization. It must be outside of the served directories. Such a file will be created later.
  • Requirevalid-user indicates that only authorized users can access this resource. It is this parameter that protects the resource from unauthorized users.

Save and close the file.

Creating the .htpasswd file

Now in the directory specified in the AuthUserFile line, you need to create a password file.htpasswd.

To do this, you will need an additional package containing the htpasswd utility, which can be installed from the standard repository:

sudo apt-get install apache2-utils

Remember, the file must be created in the directory specified in the AuthUserFile directive, in this case /etc/phpmyadmin/.htpasswd.

Create this file and pass it to the user by typing:

sudo htpasswd -c /etc/phpmyadmin/.htpasswd username

Today we will look at the installation process of a very popular web application phpMyAdmin, which is used to administer the MySQL DBMS, we will install it on the Linux Mint 18.2 operating system.

Let me remind you that earlier in the material “Installing and configuring MySQL server and MySQL Workbench on Linux Mint 18.2” we looked at the installation of the MySQL DBMS and the MySQL Workbench client application, which has a graphical interface, but many administrators use, as I already said, the very popular web application for working with MySQL, phpMyAdmin, so now, especially for beginners, I will describe in detail the process of installing phpMyAdmin on Linux Mint 18.2.

As always, we will look at installation using a graphical tool ( program manager), and using the Linux terminal.

phpMyAdmin is a free web application with a graphical interface for administering the MySQL DBMS ( MariaDB support is also available). phpMyAdmin was developed using the PHP language and since this is a web application, a web server is required for its functioning, for example, Apache or Lighttpd. The phpMyAdmin application is popular all over the world and it has currently been translated into 72 languages, including Russian.

With phpMyAdmin you can:

  • View databases and tables;
  • Create, copy, rename, modify and delete databases;
  • Create, copy, rename, modify and delete tables;
  • Add, edit and delete fields in tables;
  • Execute SQL queries;
  • Create, modify and delete indexes;
  • Load text files into tables;
  • Create and read dumps of tables and databases;
  • Export data to SQL, CSV, XML, Word, Excel, PDF and LaTeX formats;
  • Manage MySQL users and privileges;
  • And also much more.

Installing phpMyAdmin on Linux Mint 18.2

As I already said, we will look at two ways to install phpMyAdmin, and we will start with a simple method suitable for beginners, i.e. using the program manager graphical interface.

Installing phpMyAdmin using the program manager

In order to install phpMyAdmin, you must first install a Web server, such as Apache. Therefore, now we will first install Apache and only then phpMyAdmin.

Open the program manager, for example, “ Menu->Program Manager" or " Menu->Administration->Program Manager».

Enter the computer administrator password.


Installing Apache web server

In the program manager, enter Apache in the search and press Enter. Then find Apache2 in the search results and double-click on it.



The installation is complete when the window displays “ Installed».


Installing phpMyAdmin

To install phpMyAdmin in exactly the same way, enter phpMyAdmin into the search and press Enter. Most likely, only one program will be found, which is what we need, double-click on it.



During the installation process you will be asked which web server you will use, since we have already installed Apache, accordingly we answer Apache and click “ Forward».


Then there will be a question about the phpMyAdmin database, i.e. if we want to configure it, we leave the checkbox and click “ Forward».


As a setup, we are asked to come up with and enter a password for the phpMyAdmin database, we enter and click “ Forward", then confirm it and also click " Forward» ( The password should be quite complex, although you will rarely need it).



The installation is complete when the message “ Installed" After this, you can immediately check the operation of phpMyAdmin.


Installing phpMyAdmin using terminal

To launch the Linux terminal, click, for example, on the link on the panel or launch it from the Mint menu.


Installing programs, including phpMyAdmin, must be done as root, so let's switch to this user right away. To do this, write the command sudo -i (or sudo su) and press Enter ( input), then enter the user password.

Then we need to update the list of packages, for this we write a command.

Apt-get update

Then, as in the case of the program manager, we need to first install the Apache web server, to do this we enter the following command.

Apt-get -y install apache2


Apt-get -y install phpmyadmin


During the installation process we will be asked which web server we will use, we select Apache and click " Enter».


Then we need to configure the phpMyAdmin database, select “ Yes" and click " Enter».


Then we come up with and enter a password for the phpMyAdmin database, click “ Enter", in the next window we confirm the password, i.e. enter it again and press “ Enter».



After this, the installation will be completed.

Configuring Apache to work with phpMyAdmin

If we install phpMyAdmin using the terminal, then in this case, unlike the graphical installation using the program manager, we need to manually connect the phpMyAdmin configuration file ( those. phpmyadmin settings file).

To do this, we write a command (with root rights), with which we will create a symbolic link in the directory with Apache configuration files.

Ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf

Then we will enable this configuration file.

A2enconf phpmyadmin

Restart Apache

Systemctl restart apache2


That's it, after this you can proceed to checking the operation of phpMyAdmin.

If necessary, this configuration file can be disabled; for this purpose, there is the a2disconf command. After the Web server, Apache also needs to be restarted.

By the way, you can connect this configuration file in another way, for example, directly register the connection in the apache2.conf file, this method is often found on the network, but the first option in this case is more correct. To edit apache2.conf, run the command (as root).

Nano /etc/apache2/apache2.conf

Add the following line to the end of the file.

Include /etc/phpmyadmin/apache.conf

We save the file with the keyboard shortcut Ctrl+O and press Enter, then close it also with the keyboard shortcut Ctrl+X only. Apache in this case also needs to be restarted

Systemctl restart apache2

Checking the operation of phpMyAdmin, connection to MySQL

In order to check the operation of phpMyAdmin, let's launch any browser and type the following address in the address bar ( this is the local address of phpMyAdmin).

http://localhost/phpmyadmin

If you see the phpMyAdmin welcome page, then everything is fine, in other words, both the web server and phpMyAdmin are working.

To connect to the MySQL server, enter your username and password; for example, I will connect as root ( although as you know, working as root is not recommended).


After logging in, you will be taken to the phpMyAdmin home page, where you can see a list of databases on the server and the basic settings of the MySQL server.


Uninstalling phpMyAdmin in Linux Mint 18.2

You can remove phpMyAdmin either using the program manager or using the terminal. Let's look at both methods as well.

Uninstalling phpMyAdmin using Program Manager

Open the program manager, and in the same way as during installation, find phpMyAdmin. After you open phpMyAdmin in the program manager, you need to click on the “ Delete».


During the removal process, we will be asked if we want to delete the phpMyAdmin database settings, we leave the checkbox, i.e. delete the settings, click " Forward».


Then there will be a question whether we want to delete the phpMyAdmin database, we check the box and click “ Forward", i.e. We will delete the phpMyAdmin database as we no longer need it ( If you need it accordingly, then you do not check the box).


The phpMyAdmin field will be removed. Now we can disable the phpMyAdmin configuration file in the Apache web server settings. To do this, in the terminal we need to run the command ( with superuser rights).

A2disconf phpmyadmin

And restart Apache

Systemctl restart apache2


If you do not need the Apache web server, then you, like phpMyAdmin, can remove it using the program manager.


During the Apache removal process, you will not have any additional questions.

Uninstalling phpMyAdmin using Terminal

To remove phpMyAdmin using terminal, we have to launch it accordingly. Then we get root rights using sudo -i (or sudo su), since the deletion must be done with superuser rights.

To remove only phpMyAdmin, we need to first disable the phpMyAdmin configuration file. To do this, as before, we write the following command and restart Apache.

A2disconf phpmyadmin systemctl restart apache2

To remove phpMyAdmin we use the following command.

Apt-get -y --purge remove phpmyadmin

Key --purge means that we want to remove packages along with their configuration files.

During the removal process we will be asked if we want to delete the phpMyAdmin database settings, we answer “ Yes" and click " Enter».


Then, when asked about deleting the phpMyAdmin database, we also answer “ Yes", as I already said, unless of course you need it.


As a result, phpMyAdmin will be deleted.


To remove the Apache web server, write the following command.

Apt-get -y --purge remove apache2

To remove all related packages that we no longer need, we need to use the following command, thereby we can free up disk space.

Apt-get -y autoremove


That's all, I hope the material was useful to you, good luck!

Although many users have a need for a database management system like MySQL, working with MySQL only through command line tools can be frustrating.

phpMyAdmin was created to allow users to manage a MySQL database using a web interface. In this article, we'll walk you through how to install and configure phpMyAdmin to work securely with your databases on Ubuntu 16.04.

Before installation

Before we begin, make sure you have everything you need.

First of all, we will assume that you have a non-root user with sudo privileges. You can set up such a user account by following steps 1-4 in.

Finally, there are some security issues to keep in mind when using phpMyAdmin because it:

  • Interacts directly with MySQL.
  • Performs authentication using MySQL login and password.
  • Executes and returns results of arbitrary SQL queries.

For these reasons, and because phpMyAdmin is one of the most common and attacked PHP applications, you should not run phpMyAdmin on remote machines with a simple HTTP connection. If you do not yet have a domain with a configured SSL/TLS certificate, we recommend that you read the article.

After completing the steps above, you can start following the steps mentioned in this article.

Step 1 - Installing phpMyAdmin

First, let's install phpMyAdmin from the default Ubuntu repositories.

To do this, we'll update our local package index and then use the apt package management system to download and install the necessary files:

  • sudo apt-get update
  • sudo apt-get install phpmyadmin php-mbstring php-gettext

During the installation process you will be asked several configuration questions.

Attention:
During the first dialog, apache2 is highlighted, but Not selected. If you don't click Space to select Apache, installer Not will move the necessary files during the installation process. Click Space, Tab, and then Enter to select Apache.

  • When selecting a server, select apache2.
  • Reply yes when asked if you want to use dbconfig-common to configure the database.
  • You will be prompted for your database administrator password.
  • Next, you will be asked to enter and repeat the password for phpMyAdmin itself.

During the installation process, a phpMyAdmin configuration file for Apache will be added to the /etc/apache2/conf-enabled/ directory.

The only thing we have to do manually is to enable the PHP mcrypt and mbstring extensions with the following commands:

  • sudo phpenmod mcrypt
  • sudo phpenmod mbstring

You can now access the phpMyAdmin web interface by entering the domain name or public IP address of your server and the line /phpmyadmin:

https:// domain_name_or_IP_address/phpmyadmin

You can now log into the web interface using the root username and password you set during the MySQL installation process.

After logging in, you will see a similar user interface:

Step 2 - Making phpMyAdmin more secure

Installing phpMyAdmin is quite simple. However, we are not done yet. Because phpMyAdmin is used by so many users, it is a popular target for attackers. We need to take some steps to prevent unauthorized access.

One way to achieve this is to authorize the user before logging into the application itself. We can solve this problem by using the capabilities of the Apache .htaccess file for authorization and authentication of users.

Configuring Apache to allow .htaccess

First, let's enable the ability to use the .htaccess file in our Apache configuration file.

We will edit a file in our Apache configuration directory:

  • sudo nano /etc/apache2/conf-available/phpmyadmin.conf

We need to add the AllowOverride All directive to the section configuration file:

/etc/apache2/conf-available/phpmyadmin.conf

Options FollowSymLinks DirectoryIndex index.php AllowOverride All . . .

To apply the changes, restart Apache:

  • sudo systemctl restart apache2

Creating the .htaccess file

Now that we have enabled .htaccess for our application, we need to create such a file.

The file must be created in the application directory. We can create the required file and open it for editing with the following command:

  • sudo nano /usr/share/phpmyadmin/.htaccess

Now let's enter the following information:

/usr/share/phpmyadmin/.htaccess

AuthType Basic AuthName "Restricted Files" AuthUserFile /etc/phpmyadmin/.htpasswd Require valid-user

The lines we entered mean the following:

  • AuthType Basic: This string specifies the authorization type. The specified type (Basic) means that authorization will be based on a password and a password file.
  • AuthName: This line specifies the greeting text in the authorization dialog. Use common words and phrases in this line to make it more difficult for attackers to determine what kind of system is hidden behind the authorization dialog.
  • AuthUserFile: This line specifies the address of the password file that is used for authorization. The file must be located in a directory that is inaccessible to the outside world. A little later we will create this file.
  • Require valid-user: This line means that only authenticated users can access the protected system.

After entering the specified lines, save and close the file.

Creating a password file.htpasswd for authentication

Now that we have set the path for our password file in the AuthUserFile directive in our .htaccess file, we need to create this file.

In order to do this, we will need to install an additional package from the standard repositories:

  • sudo apt-get install apache2-utils

Now we have access to the htpasswd utility.

The path we specified earlier looked like this: /etc/phpmyadmin/.htpasswd. Let's create this file and add the first user to it with the following command:

  • sudo htpasswd -c /etc/phpmyadmin/.htpasswd username

You will be asked to select and confirm a password for the created user. After this, the file will be created and the hash of the password you specified will be added to it.

To add a new user run the following command without-c flag:

  • sudo htpasswd /etc/phpmyadmin/.htpasswd additionaluser

Now that you have configured access to the phpMyAdmin subdirectory, when you try to log into phpMyAdmin you will be prompted to enter your username and password:

https:// domain_name_or_IP_address/phpmyadmin

After entering your username and password, you will be redirected to the phpMyAdmin authentication page. Thus, we have created an additional layer of protection for your phpMyAdmin.

Conclusion

You now have phpMyAdmin ready to run on your Ubuntu 16.04 server. Using its interface, you can easily create databases, users, tables and more, as well as perform routine modification or deletion operations on stored data.