Author: Ricky Bryce (Montgomery County, Illinois)
| Click here to learn why Christ came to this Earth for us! | Get 10% off VPSLink! Enter REFERRAL code MJDCDJ |
MySQL (Database Server)
MySQL is a database server, and plays a major role in dynamic web pages, such as guestbooks and forums. This lesson will walk you though how to set up a MySQL Database for your user.
Before we do anything with MySQL, we need to log into your server using PUTTY, and set the root password for MySQL. This password does not have to be the same password as your Linux system account. I'm going to assume that you are logged in as a standard user.
Now, type su to access super user priviledges.
Now, type /etc/init.d/mysqld start to start mysql server. Notice the 'd' after mysql (daemon) Here you can see I typed the command incorrectly the first time. Later on, we'll configure MySQL to start automatically when the virtual machine boots.

Now, type this command. mysqladmin -u root password Gr8Us7 Obviously, you will substitute Gr8Us7 for the password you wish to use. In the future if you wish to change the root password, just use the same command, but type a -p after mysqladmin, and you will be prompted for the old password before the new password is active.
Now let's install phpmyadmin into the server, so users can access their databases. Just type “yum install phpmyadmin” at the command prompt for root.
You will be asked to verify it's OK to install the packages, then you should get a message stating the install is complete.

Next, we will need to set a directive in the apache configuration file to allow users to access the phpmyadmin program we just installed, so they have an easy way to administer their database. Type cd /etc/httpd/conf/
![]()
type vi httpd.conf to edit the apache configuration file.
![]()
Hold Control + F (control and F at the same time) until you reach the end of the file. This is where our custom configuration is located for virtual hosting.
Tap “i” for insert mode.
Use the up arrow key to move above our first virtual host entry, and the virtual host example we used when configuring the virtual hosts in the Apache lesson. You will place your cursor at the end of the line maked NameVirtualHost *:80 as shown.

Press the enter key a couple times, and add the directory directive as shown.

Press the escape key on your keyboard (esc) to return to command mode.
Type :wq (colon, then w for write, and q to quit)
Restart apache by typing /etc/init.d/httpd restart

Now, let's give our user a database they can access. To do this we can go to webmin, and under servers, click MySQL Database Server. Remember, we set up webmin earlier, and to access webmin, just go to https://brycefamily.com:10000 (substitute your own domain)

Now, login with the root username and password which you set up earlier in this lesson., and save your changes.

Create a new database.

I'm going to create this database as ricky_main. This helps me to determine which databases belong to specific users, and also helps to group the databases together by username. We'll let the users create their own tables. Click “Create” once you have the database name in place.

Now, we'll have to relate the user “ricky” to this specific database. Under “Global Options”, click “User Permissions”

Create a new user.

Enter the username and password for the user, and I'm limiting the host to “localhost” with no other priviledges. We will configure this user's priviledges at the database level. Click “Create” to build the user.

Verify the new user has been added.

Return to the database list
![]()
Now, let's go to “Database Permissions”

Now, we'll “Create New Database Permissions”:

Now, we'll grant the user “ricky” all privileges to his database (ricky_main). To select all privileges, select the first item in the privilege list, then hold “shift” on your keyboard, and select the last item in the privilege list. Click “Create” to build the permission.

Verify the permission was created:

Now let's reboot the server just to ensure all changes are active. To reboot the server, just go to PUTTY (which is probably still running), and type reboot. You will need to be root to reboot the server.

Using PUTTY, you need to log back into your server.
If you logged in a a standard user, type su to become the root user.
Type /etc/init.d/mysqld to start MySQL (we will set it to automatically start in a later lesson)

Now, go to your web browser, and enter http://brycefamily.com/phpmyadmin in the address bar. As you can see, we are getting close, but still not quite there yet. We'll take care of this error in the next step, but you should see something like what is shown in the image below. If not read the notice below the image.

Notice!! If you are forbidden from accessing the directory, the /usr/share/phpmyadmin line in the <directory> directive in the httpd.conf file is case sensitive. I noticed in CentOS 5, phpmyadmin is all lower case when installing with YUM, but Fedora was phpMyAdmin. To check this, log onto the server with root privileges in PUTTY. Type cd /usr/share Then type ls to list the contents of the directory. Make note exactly how the phpmyadmin directory is spelled (case sensitive), and ensure this is what you used in step 12 above. If you still have trouble, be sure phpmyadmin is installed (type yum install phpmyadmin) Also, be sure the <directory> directive is entered exactly as shown in step 12. You can also try to reboot the server if you still have issues.
Now, let's take care of this error we care getting. We need to enter a secret passphrase just for the purpose of encryption.
In putty (as root), type cd /usr/share/phpmyadmin If you get an error, try cd /usr/share/phpMyAdmin (if that is how your directory is cased)
Now, type vi config.inc.php (This will allow us to edit the config file for phpmyadmin)
type /blowfish (forward slash, then blowfish. This will search for the blowfish text)
Tap “i” to get to insert mode.
Cursor over between the two apostrophes, and enter a passphrase of your own. (be sure the passphrase is between the two apostropes!!!)

Press esc on your keyboard to escape to command mode.
Now type :wq (colon, then w for write, and q for quit)
Now, I'm going to brycefamily.com/phpadmin, and I at least get a login screen, but I still get another error. We are taking this one step at a time. In the next step, we will resolve this error.

In PUTTY, type yum install php-mcrypt as the root user. You will be asked to confirm the installation. You will be informed when the installation is complete.

Now, I'm going to go back to http://brycefamily.com/phpmyadmin, and should get a login screen without errors (again, use your own domain)
.If so, login to phpmyadmin If you still have errors, you might try a google search to figure out how to correct them. You are using the password you gave the user when you assigned them database permissions.

The user can now create tables. Again, you are responsible for verifying security, but if you are the only user, and you are the administrator of all the web pages, you will have less to worry about!