Installation

only for RuBoard - do not distribute or recompile

Installation

Installation using the Red Hat Package Manager is extremely easy and painless, not to mention nearly trouble-free. A few commands, and you will be on your way

Installing from the RPM

This is the easiest and, in my opinion, the best way to install MySQL if you are interested in immediate results. Because Red Hat is one of the most common Linux distributions, you can usually expect the RPM to get the job done. If your distribution supports this installation method, I highly recommend that you use it. It does, however, decide the default location for files, which makes you do some searching to know how your MySQL server is configured.

Installing the RPM

The RPM installation for MySQL presented in this book proceeds as follows : First, the server portion is installed (the process that serves up the requests from the mysql client), and then the client is installed (the normal way to query a MySQL database). This assumes that both will be loaded on the same machine. You will then test the installation, and finally, you will install the files needed for C program development.

Install the Server

You should note the location of certain files that the RPM will install for you. To do so, send the following command:

 % rpmqpl /usr/tmp/MySQL-3.23.21-1.i386.rpm  more 

Use the space bar to view one screen at a time, and note the location of the safe_mysqld program. The more part of the command allows you to view one screen at a time using the space bar. Find the safe_mysqld program, and note its location in the directory tree. In my case, it was /usr/bin.

To install, type the following command:

 % rpmi /usr/tmp/MySQL-3.23.21-1.i386.rpm 

If you re running Linux-Mandrake, you can simply double-click on the file from the KDExplorer or whatever file manager you re using.

Install the Client

To install the client, type the following command, this time noting the location of the mysqladmin program and its location in the directory tree. The following command queries the package so that I can see the location of the mysqladmin utility:

 % rpmqpl /usr/tmp/MySQL-client-3.23.21-1.i386.rpm 

In my case, the mysqladmin program was located in the /usr/bin directory. To actually install the package, use this code:

 % rpmi /usr/tmp/MySQL-client-3.23.21-1.i386.rpm 
Test the Installation

These steps require that both the server and the client portions be installed. Type the following commands:

 % cd /usr/bin  % mysqladmin version 

If you get a response, the MySQL server daemon is running on your machine. The response should be something like the following (note that it will probably change with a different version that you will install after this book is published):

 mysqladmin Ver 8.13 Distrib 3.23.29a-gamma, for linux on i586  Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB  This software comes with ABSOLUTELY NO WARRANTY. This is free software,  and you are welcome to modify and redistribute it under the GPL license  Server version          3.23.29a-gamma  Protocol version        10  Connection              Localhost via UNIX socket  UNIX socket             /tmp/mysql.sock  Uptime:                 6 hours 23 min 45 sec  Threads: 2 Questions: 938581 Slow queries: 0 Opens: 30  Flush tables: 1 Open tables: 2 Queries per second avg: 40.764  mysqladmin Ver 8.7 Distrib 3.23.21-beta, for pc-linux-gnu on i686  TCX Datakonsult AB, by Monty  Server version          3.23.21-beta-log  Protocol version    10  Connection          Localhost via UNIX socket  UNIX socket         /var/lib/mysql/mysql.sock  Uptime:             37 min 45 sec  Threads: 1 Questions: 3 Slow queries: 0 Opens: 6 Flush tables:  1 Open tables: 2 Queries per second avg: 0.001 

Another way to verify that your database server is functioning is to enter

 % mysql 

This changes the prompt from % to mysql> . Type

 mysql> select now(); 

This should give you a response like the following:

 +---------------------+   now ()                +---------------------+   2000-07-05 08:31:28   +---------------------+  row in set (0.01 sec) 

Finally, you can use this command

 % mysqladmin ping 

which returns the following (if your MySQL server is functioning):

 mysqld is alive 

You now have a running ”but unsecured! ”MySQL database server on your computer.

Install the Files for C Development

If you will be doing any program development, you need to install the files for C development. First, type

 % rpmqpl /usr/tmp/MySQL-devel-3.23.25-1.i386.rpm 

and note the location of mysql.h . In this case, it is /usr/include/mysql/ . You should also note the location of libmysqlclient.a . To install, send the following command:

 % rpmi /usr/tmp/MySQL-devel-3.23.25-1.i386.rpm 

You need to know the location of mysql.h and libmysqlclient.a for program development later in this book.

Uninstall the RPM

You may or may not need to do this, but I want to include it here for completeness.

First, you need to shut down the server:

 % mysqladmin shutdown 

Then enter the following command to find out the package name in the RPM package database:

 % rpmqa 

The MySQL package(s) will probably appear at the bottom of the list, because they were installed most recently. It is important for you to know that you cannot simply give the rpm “e command with the original filename that you used to install. You must find out what the Red Hat Package Manager calls the packages you want to remove. To uninstall the packages, type

 % rpmevv MySQL-3.23.21-1 

followed by

 % rpmevv MySQL-client-3.23.21-1 

The “e option is for uninstall (erase), and the “vv is for verbose mode. Otherwise, you will have no idea what is happening; you will only know the operation is complete when your command prompt reappears.

Installing the Account to Administer the MySQL Server

If you re installing from RPM, the mysql user account is created automatically. If, after installing MySQL from the RPM, you look at the user accounts on your system (for example, using the linuxconf utility), you will see that there is a user with the login name mysql (although previously it might have been mysqladm or something similar, and it might change again in the future). The full name will be something like MySQL server, and the home directory will be something like /var/lib/mysql. This is a user that can be managed just like a real person who logs onto the machine; it can have administrator privileges as well as others.

Starting and Stopping the MySQL Server Daemon

When you install from an RPM, the MySQL server daemon is started and stopped automatically for you, and the daemon is added to the boot and shutdown sequence of the machine on which it is installed. If you don t know what a daemon or process is on a database server, refer to the earlier section For Access Converts Only: Daemons and Services.

If for some reason you need to start up the MySQL daemon, enter this code:

 % cd /usr/local/mysql/bin  % safe_mysqlduser=mysql & 

The & specifies a background process.

To enable logging, send

 % safe_mysqlduser=mysqllog & 

or

 % safe_mysqldlog & 

You could also use the --log-bin option, which would make accidentally deleted data recoverable.

You should log as much as you can until you get comfortable with MySQL.

To shut down the MySQL server daemon, send the following command:

 % mysqladmin shutdown 
Changing the mysqladmin Password

For added security, you need to change the password for the root user of mysql. This is done with either of the following commands:

 /usr/bin/mysqladminu rootp password 'new-pas' 

or

 /usr/bin/mysqladminu rooth servernamep password 'new-password' 

In this case, you have to be root and know the root password to change the password. To remove a password, try this:

 mysqladmin -p password "" 

Also remember that you can use SQL statements to update the user table. (Issue the Show Databases command to see it; one of the databases listed will be named mysql ”that is the system database.) Setting the Password field to a zero-length string effectively removes the password.

only for RuBoard - do not distribute or recompile


MySQL Building User Interfaces
MySQL: Building User Interfaces (Landmark)
ISBN: 073571049X
EAN: 2147483647
Year: 2001
Pages: 119

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net