Linux:Powerful Server Administration
上QQ阅读APP看书,第一时间看更新

Installing web access for MySQL

In this recipe, we will set up a well-known web-based MySQL administrative tool—phpMyAdmin.

Getting ready

You will need access to a root account or an account with sudo privileges.

You will need a web server set up to serve PHP contents.

How to do it…

Follow these steps to install web access for MySQL:

  1. Enable the mcrypt extension for PHP:
    $ sudo php5enmod mcrypt
    
  2. Install phpmyadmin with the following commands:
    $ sudo apt-get update
    $ sudo apt-get install phpmyadmin
    
  3. The installation process will download the necessary packages and then prompt you to configure phpmyadmin:
  4. Choose <yes> to proceed with the configuration process.
  5. Enter the MySQL admin account password on the next screen:
  6. Another screen will pop up; this time, you will be asked for the new password for the phpmyadmin user. Enter the new password and then confirm it on the next screen:
  7. Next, phpmyadmin will ask for web server selection:
  8. Once the installation completes, you can access phpMyAdmin at http://server-ip/phpmyadmin. Use your admin login credentials on the login screen. The phpmyadmin screen will look something like this:

How it works…

PHPMyAdmin is a web-based administrative console for MySQL. It is developed in PHP and works with a web server such as Apache to serve web access. With PHPMyAdmin, you can do database tasks such as create databases and tables; select, insert, update data; modify table definitions; and a lot more. It provides a query console which can be used to type in custom queries and execute them from same screen.

With the addition of the Ubuntu software repository, it has become easy to install PHPMyAdmin with a single command. Once it is installed, a new user is created on the MySQL server. It also supports connecting to multiple servers. You can find all configuration files located in the /etc/phpmyadmin directory.

There’s more…

If you want to install the latest version of phpMyAdmin, you can download it from their official website, https://www.phpmyadmin.net/downloads/. You can extract downloaded contents to your web directory and set MySQL credentials in the config.inc.php file.

See also