There are many ways to manage MySQL database servers. The most popular and easiest way to manage MySQL is using your web browser via phpMyAdmin tool.
PhpMyAdmin is a PHP application that enables webmasters and database administrators to easily manage and maintain MySQL databases via popular web browsers. For anyone just starting our with MySQL, it’s recommended to install phpMyAdmin and manage your databases that way.
This brief tutorial is going to show you how to install phpMyAdmin on Ubuntu 14.10 so that you can easily manage your databases. Furthermore, I will show you how to enable self-signed SSL so that accessing your database via the web is also secured and protected.
Since phpMyAdmin is a PHP tool and relies on PHP and Apache2 to function, you should install the LAMP stack on your systems. The LAMP stack will install everything that phpMyAdmin needs to function.
To install the LAMP stack, read our previous post on it. We detailed a step-by-step guide to installing the LAMP stack here.
After installing LAMP, continue below to install phpMyAdmin
- Installing phpMyAdmin
To install phpMyAdmin, run the commands below. phpMyAdmin is part of the default Ubuntu repository and comes ready to be installed. Just run the commands below to get it.
sudo apt-get install phpmyadmin
When prompted to select a web server, select Apache2, then select Yes to allow phpMyAdmin to be configured automatically.
Enter the password you entered during MySQL installation, then create a password for phpMyAdmin. They can both be the same password.
After that, open Apache2 main configuration file and add the line below so it loads phpMyAdmin scripts.
sudo vi /etc/apache2/apache2.conf
Then add the line below almost at the bottom of the file and save it.
Include /etc/phpmyadmin/apache.conf
Restart Apache2 by running the commands below.
sudo service apache2 restart
At this time, you should be able to go to your host server IP followed by /phpmyadmin to bring up phpMyAdmin logon page.
You can logon using the root username and password but the traffic isn’t secured. To secure it, you must install and enable SSL (even self-signed).
To enable SSL traffic, continue below.
- Enable SSL for phpMyAdmin
To enable SSL, run the commands below. The commands below enables the SSL module for Apache2
sudo a2enmod ssl
Next, create a directory to install your encryption key.
sudo mkdir /etc/apache2/ssl
Then change into that directory
cd /etc/apache2/ssl
Run the commands below to generate a self-signed SSL encryption key
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
To generate a key, you’ll be prompted to enter some information. Follow the guide below to create one
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:Minnesota
Locality Name (eg, city) []:Minn
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Blog
Organizational Unit Name (eg, section) []:Dept of Blogging
Common Name (e.g. server FQDN or YOUR name) []:myblog.com
Email Address []:[email protected]
If you’re running a live production site and public SSL key that’s trusted by a Certificate Authority, you can add the SSL key for the entire site. Don’t do this on your live site using self-signed SSL certificate. All your visitors will be prompted to trust the key as it’s not verified.
On your non-production site, open Apache2 default site config file
sudo vi /etc/apache2/sites-available/000-default.conf
Then change the line as shown below.
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName myblog.com:443
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
Save the file and you’re done.
Finally, open phpMyAdmin file
sudo vi /etc/phpmyadmin/config.inc.php
Then add the line below to the bottom of the file to force SSL for phpMyAdmin
$cfg['ForceSSL'] = true;
Restart Apache2
sudu service apache2 restart
Now you can go to your host using HTTPS to access it. You need a valid SSL certificate from a CA if you want to run it on your live production site. For test environment, you Self-Signed certificates.
Enjoy!
Frequently Asked Questions
How to install phpMyAdmin on Ubuntu 14.10?
To install phpMyAdmin on Ubuntu 14.10, you can run the command 'sudo apt-get install phpmyadmin' in the terminal. Make sure to select Apache2 when prompted and configure phpMyAdmin with your MySQL password.
What is phpMyAdmin and how does it help manage MySQL databases?
phpMyAdmin is a PHP application that enables webmasters and database administrators to easily manage and maintain MySQL databases via web browsers. It provides a user-friendly interface for tasks like creating, editing, and deleting databases and tables.
How to enable SSL support for phpMyAdmin on Ubuntu 14.10?
To enable SSL support for phpMyAdmin on Ubuntu 14.10, you can create a self-signed SSL certificate and configure Apache to use SSL. This adds a layer of security when accessing your database via the web.
What is the LAMP stack and why is it needed for phpMyAdmin?
The LAMP stack consists of Linux, Apache, MySQL, and PHP, which are essential components for hosting web applications like phpMyAdmin. It provides the necessary environment for phpMyAdmin to function properly.
How to add phpMyAdmin scripts to Apache2 configuration file?
To add phpMyAdmin scripts to the Apache2 configuration file, you can edit the '/etc/apache2/apache2.conf' file and include the line 'Include /etc/phpmyadmin/apache.conf'. This ensures that Apache2 loads phpMyAdmin scripts correctly.
What is the purpose of selecting Apache2 during phpMyAdmin installation?
Selecting Apache2 during phpMyAdmin installation allows for automatic configuration of phpMyAdmin with Apache2 web server. This ensures that phpMyAdmin functions properly within the Apache2 environment.
Can the MySQL password and phpMyAdmin password be the same during installation?
Yes, during phpMyAdmin installation, you can choose to use the same password for both MySQL and phpMyAdmin. This simplifies the management of database access credentials.
Why is it recommended for beginners to install phpMyAdmin for MySQL management?
For beginners, installing phpMyAdmin provides a user-friendly interface to manage MySQL databases without the need for complex command-line operations. It simplifies tasks like database creation, table management, and data manipulation.