Our plan is first to install the MySQL server and ensure that it works. Then we'll install PHP and Mod_SSL. We will then install the Apache web server. Finally, after we have installed Apache we will test to see if PHP and Mod_SSL are functioning correctly. You should note that:
Text that is indented and between horizontal rules is the expected input and output to and from your computer. The black text is what you enter. The red text means that you may have to change it to fit your circumstances. The green text is what the computer should display by itself.{mospagebreak title=MySQL Source Installation (*NIX)} The basic commands to unpack and install the MySQL source distribution from a `tar' file: Become ROOT by using su. Change directly to where you have the tar file. (use a temp directory. I used /tmp/download/) Extract the files using the following command. Change to the NEW directory which was created during the extract. Now you can run "configure" for the MySQL server. You can specify many options with the configure command. Type "configure --help" to see all options. We're using the "--prefix" option to specify the direct path to the installation location. Configure will check for your compiler and a couple of other things. If you have any errors you can check the config.cache file to see the errors. After you are done with the configure. You can make the actual binaries by executing the following line (this will take a while). Now you are ready to install all the binaries. Run the following lines to install the binaries to the directory you specified with the configure "--prefix" option. Now it is time to create the mysql tables used to define the permissions. Make sure you replace "new-password" with something of your choice, otherwise, new-password will be your root password. You can ensure that MySQL is working by running some simple tests to verify that the server is working. The output should be similar to what is shown below: # BINDIR/mysqlshow -p Enter password:
Once you install MySQL, it will automatically create two databases. One is the mysql table which controls users, hosts, and database permissions in the actual server. The other is a test database. We could use the test database, however, we want to give you a quick and simple overview of some of the command line options available with MySQL. Also, this will ensure that root has been set up with full access to the database server (i.e. root has permission to create databases, tables, etc.) We will create a "test2" database that we will use later for our testing after logging into the MySQL server. #mysql -u root -p Enter password: mysql> show databases;
mysql> create database test2; Query OK, 1 row affected (0.00 sec) Now select the test2 database, and create a new table called tst_tbl, with the two following fields. Field 1, which is an id field which lets you know the id of the record. Essentially, this is just a row number for simplicity. The second field is a name field in which you will store name information about books. The formats for these fields are.. field 1 (id) is an integer (int) of length 3, and field 2 (name) is a character (char) field of length 50. We assign id to be the key for searching and indexing the data. y NOTE: MySQL commands are not case-sensitive. For example, CREATE and cReatE will be interpreted the same way. Also, remember to add a semi-colen after your commands. mysql> use test2; Database changed mysql> CREATE TABLE books ( -> id int(3) not null auto_increment, -> name char(50) not null, -> unique(id), -> primary key(id) -> ); Query OK, 0 rows affected (0.00 sec) Now we can verify that indeed everything is correct with the following commands. mysql> show tables;
mysql> describe books;
Notice that the describe command basically "describes" the table layout. Pretty cool hey?! Ok, time for some really useful SQL commands, inserting and selecting data from the database. It's time to add several records to the new table. Remember these are simple records of book names, but once you have gained enough experience with SQL you can create really complex databases for some great e-commerce sites. Let's create two records of two fictitious books. The first record is the name of a book I plan on writing some day, "PHP 4 Newbies." The other is a useful book for Linux, "Red Hat Linux 6 Server", by Mohammed J. Kabir. mysql> INSERT INTO books (name) values('PHP 4 Newbies'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO books (name) values('Red Hat Linux 6 Server'); Query OK, 1 row affected (0.00 sec) Now we can check the new records, and issue a select all command. mysql> SELECT * from books;
Great, the MySQL server is fully functional. We could continue to add records, but it makes no sense at this time. Notice how you did not have to specify the id number when you inserted the record in the database. This is because you created the id field with the auto_increment option enabled. Let's learn how do a quick delete. This is just for your info, remember that you can find everything you may need about the MySQL commands and the server at the mysql web site at http://www.mysql.com. mysql> delete from books where id=1; Query OK, 1 row affected (0.00 sec) mysql> select * from books;
Ok, exit MySQL and continue with the setup...you can play with MySQL later after you have completed all the installations and everything is working properly.
blog comments powered by Disqus |
|
|
|
|
|
|
|