Install MySQL server + PHP + phpMyAdmin

Note

MySQL is a database server.

PHP (PHP5 before Ubuntu 16.04) is a web page programming language.

phpMyAdmin is a web interface to administer the MySQL server.

Install PHP and related apache2 module (Ubuntu 16.04)

$ sudo apt install php libapache2-mod-php

Restart Apache2 service:

$ sudo systemctl restart apache2.service

Install PHP5 and related apache2 module (before Ubuntu 16.04)

$ sudo apt-get install php5 libapache2-mod-php5

Enable the module:

$ sudo a2enmod php5

Restart Apache2 service:

$ sudo systemctl restart apache2
or
$ sudo service apache2 restart

Install MySQL and related PHP module (Ubuntu 16.04)

$ sudo apt install mysql-server
$ sudo systemctl restart mysql.service

Install MySQL and related PHP5 module (before Ubuntu 16.04)

$ sudo apt-get install mysql-server php5-mysql
  • note: libapache2-mod-auth-mysql, as suggested by some websites, is not required

Install phpMyAdmin (Ubuntu 16.04)

$ sudo apt install phpmyadmin

Enable Apache2 config:

$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
$ sudo a2enconf phpmyadmin.conf

Restart Apache2 service:

$ sudo systemctl restart apache2.service

Install phpMyAdmin (before Ubuntu 16.04)

$ sudo apt-get install phpmyadmin

Enable Apache2 config:

$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled/phpmyadmin.conf

Restart Apache2 service:

$ sudo systemctl restart apache2
or
$ sudo service apache2 restart

Create a database user and a database

 http://localhost/phpmyadmin
  or
 http://www.kctang.com.hk/phpmyadmin

Enter login name and password.

Create a user called <name, e.g. Drupal7> together with a database also called <name>:

  • click "Users" at the top menu bar
  • click "Add user" at the page middle
  • enter <name> at the User name entry
  • select "Local" at the Host entry
  • enter and re-type the password
  • click "Create database with same name and grant all privileges"
  • click "Go" at the bottom