This Is Your Brain On Informatics: User Interfaces

From Pathology Education Instructional Resource
Jump to: navigation, search

Contents

Introduction

While MySQL can be run completely from the command line, it is very useful in many circumstances to have an interface that allows easy manipulation of the database structure. This can be especially helpful for some of the more complex SQL syntax structures such as creating a user and assigning a password or uploading a CSV (comma separated values) file. Additionally, when creating and modifying tables with a scripting language such as PHP, this can be very helpful for viewing and quickly seeing if the script is working. Below are two of the more popular interfaces for MariaDB, SQLbuddy and phpMyAdmin; however, there are several others.

SQL Buddy

Overview

SQLbuddy is a very minimal user interface for MariaDB. It's advantage is that it is a light interface making it very fast. Also, it is not used as much as phpMyAdmin, which means it is more secure due to being a smaller profile target. However, these advantages bring the disadvantage of SQLbuddy not having a heavy user interface including its lack of syntax highlighting for SQL queries.

Installation

SQLbuddy can be acquired from http://sqlbuddy.com/. This site will allow the user to download a zip file of the user interface. Move this file to the server using an ftp client (such as filezilla) and then use mv to move the zip file to the directory shown below. Remain there for the rest of installation.

/usr/share/nginx/html

In order to unzip the file, unzip must first be installed on the server. If it is not type:

aptidude install unzip

Then, unzip the file by typing:

unzip sqlbuddy.zip
rm -rf sqlbuddy.zip

This method of download should have all of the files located directly under the sqlbuddy directory; however, this needs to be confirmed first. Type:

ll sqlbuddy

If there is a single directory listed named src then the files, which are embedded in sqlbuddy/src need to be moved to sqlbuddy. Do this by typing:

mv sqlbuddy/src/* sqlbuddy
rm -rf sqlbuddy/src/

If there are multiple files in the sqlbuddy directory, ignore the above command.

Now, a configuration must be done in the www file so that the index.php will be recognized as the primary site. Go to the file shown below using pico (or any other text editor of your choice).

/etc/nginx/sites-available/www

In this file, add index.php to the line shown below (shown with index.php added already).

index index.html index.htm index.php

Finally, the www file needs a location for SQLbuddy. While still in the www file, add this block of code below the current locations to set up a new location on the server for SQLbuddy:

location ~ /sqlbuddy/.*\.php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_pass php5-fpm-sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
}

Reload NGINX:

/etc/init.d/nginx reload

Sqlbuddy should now be able to be accessed by typing in yourservername/sqlbuddy into the browser.

Troubleshooting

There are still some quirks that may need to be worked out at this point.

Firefox

Firefox is excellent at tracking history; however, because of this, anything that was done incorrectly during the setup of sqlbuddy, mariadb, or even php will be remembered by the browser. If firefox is your browser of choice, it will be necessary to clear any history, after doing any major troubleshooting in order to allow those changes to take effect in firefox.

phpMyAdmin

Overview

The interface phpMyAdmin is actually one of the most popular web server database interface tools. Unfortunately, this comes with the downside of being the most common target for hackers, making it a much larger security vulnerability than SQLbuddy. Also, it is not quite as lightweight, meaning it is slightly slower (not really noticeably with small queries though). But what it lacks in those departments, it makes up in sheer user friendliness. It is very easy to use this interface to manipulate a database without even really knowing any SQL (something that should NOT be indulged in by someone writing code, but it still makes manipulations easy). If SQL is the way to go for you, the SQL editor will highlight the syntax intelligibly to make it easier to read and spot errors. The choice really depends on your needs: quick and nimble without unneeded bells and whistles or slightly slower with heavy user interface.

Installation

This is pretty much a repeat from above, so this time we'll use a slightly different method to show how it works. Go to http://www.phpmyadmin.net/ and right click on Download. Then click on the selection that will copy the link to the clipboard (copy link address for Google Chrome). Now go to the following location in the server and remain there for the rest of the installation:

/usr/share/nginx/html

Use the command wget and paste the link address into command line after it.

Now unzip the file (again, this will need to be installed if it has not been already.

unzip phpMyAdmin-4.1.5-all-languages.zip
mv phpMyAdmin-4.1.5-all-languages.zip phpMyAdmin
rm -rf phpMyAdmin-4.1.5-all-languages.zip

Also, the type of index file that NGINX recognizes will need to be changed so that it recognizes index.php if it has not been done so already.

And lastly, we need to make a location for phpMyAdmin just as for SQLbuddy. Access the following file with your favorite text editor:

cd /etc/nginx/sites-available/www

Then, add this block of code below the current locations to set up a new location on the server for SQLbuddy:

location ~ /phpMyAdmin/.*\.php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_pass php5-fpm-sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
}

Reload NGINX:

/etc/init.d/nginx reload

phpMyAdmin should now be able to be accessed by typing in yourservername/phpMyAdmin into the browser.