Home arrow Site Administration arrow Page 3 - Setting Up Database Driven Websites

Installing MySQL - Administration

This tutorial is an introductory guide to get you started in the world of server-side-scripting and web databases. It covers installation and configuration of MySQL, Apache, and PHP. An example script is also included as a guide for making your own server-side-scripts.

TABLE OF CONTENTS:
  1. Setting Up Database Driven Websites
  2. Requirements
  3. Installing MySQL
  4. Installing Apache
  5. Installing PHP
  6. Creating the Database
  7. Making a PHP Script
  8. Testing the Script
By: Ying Zhang
Rating: starstarstarstarstar / 17
May 20, 1999

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Okay, we actually get to do something now! Assuming you've downloaded everything into /tmp, do this to install MySQL.

The MySQL file you downloaded will be called something like mysql-3.22.21-pc-linux-gnu-i686.tar.gz, depending on your platform.. Extract this into /usr/local, you must do this as root:


$ cd /usr/local $ su # gzip -dc mysql-3.22.21-pc-linux-gnu.i686.tar.gz | tar -xvf

After it extracts everything, a directory called mysql-3.22.21-pc-linux-gnu-i686 (or similar) will be created. We make a symlink to this directory and give it a friendlier name:


# ln -s mysql-3.22.21-pc-linux-gnu-i686 mysql

Next time there is a new version of MySQL, you can just extract the binary distribution to a new directory and change the symlink.

Creating a MySQL User

Now we will create a user account to run the MySQL server daemons and to own all the MySQL files. Add a new user called mysql on your system using whatever commands are available for your OS (eg. useradd). No one should be logging into this account, so disable logins by:

  • setting the account expiry to a date in the past
  • entering NP or * in the password field of /etc/passwd or /etc/shadow
  • whatever your OS recommends
Preparing MySQL

First let's change the ownership of MySQL directories and files to be owned by the mysql user and the root group:


# cd /usr/local # chown -R mysql mysql-3.22.22-pc-linux-gnu-i686 mysql # chgrp -R root mysql-3.22.22-pc-linux-gnu-i686 mysql

Now we have to run a little script that creates the initial MySQL database, do this a the mysql user. This is the only time we use this account directly:


# su mysql $ cd mysql $ scripts/mysql_install_db $ exit

If that didn't give you any error messages, you're well on your way.

Make MySQL Start Automatically

MySQL comes with a little startup script in /usr/local/mysql/support-files called mysql.server. Make sure it is executable:


$ chmod +x /usr/local/mysql/support-files/mysql.server

You should call this from one of your system startup scripts. As this is different for every operating system, refer to your system manual for more information on how to do this.

Testing MySQL

MySQL comes with a sample database called test and its internal database that keeps track of permissions and users, so let's fire it up and see if everything is working so far. First start up MySQL:


# /usr/local/mysql/support-files/mysql.server start

If that worked, you should be able to something like:


Starting mysqld daemon with databases from /usr/local/mysql/var

The MySQL programs files are located in /usr/local/mysql/bin, you may want to this to your path. Start the client by running:


# mysql

You should see the following:


Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 to server version: 3.22.22 Type 'help' for help. mysql>

Next, list the installed databases by typing show databases:


mysql> show databases;

You should see:


+----------+ | Database | +----------+ | mysql | | test | +----------+ 2 rows in set (0.00 sec)

If you did, then it's working!! Exit MySQL by typing exit:


mysql> exit; Bye

Changing the Admin Password

The first thing to do after everything works is to change the administrator password. Do this by running mysqladmin (remember that it may not be in your path):


# mysqladmin -u root password newpassword

This sets the password for the user root to newpassword. You probably don't want to use that, so substitute it with something clever.



 
 
>>> More Site Administration Articles          >>> More By Ying Zhang
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

SITE ADMINISTRATION ARTICLES

- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: