Running Linux, 5th Edition - Matthias Kalle Dalheimer [450]
If you want to build MySQL on your own, you need to download the source package, unpack it, and install with the following commands:
owl$ ./configure --prefix=/usr/local/mysql
owl$ make
owl#make install
Note that depending on your system, you might select a different installation path. You will also probably need to be root for the third step. You need to remember the installation path because you will need it for the PHP configuration later on.
For the next step, we recommend that you create a user and a group called mysql as described in "Creating Accounts" in Chapter 11. Change to this user with su - mysql and execute:
owl$ scripts/mysql_install_db
For security reasons, it might be a good idea to disable logins by the mysql user. You can simply do this as root by putting a star in the second (password) column in /etc/password or /etc/shadow, or both.
After this step, you need to perform just one more command before returning from root to your normal user account. The following command starts the MySQL server:
owl# /usr/local/mysql/bin/mysqld_safe &
You might also want to add either the option -- log or the option -- log-long-format in order to get a logfile about what is going on in the database server.
To check whether your server was started correctly, you can try (as a normal user again) the following command (you need to change the path, of course, if you have installed MySQL in a different location):
owl$ /usr/local/mysql/bin/mysqladmin version
mysqladmin Ver 8.41 Distrib 4.1.13, for suse-linux on i686
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 4.1.13
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 43 days 11 hours 39 min 17 sec
Threads: 1 Questions: 142 Slow queries: 0 Opens: 160 Flush tables: 1 Open
tables: 13 Queries per second avg: 0.000
This should work without entering a password. We would like to point out, though, that it is not a good idea to have a database without a password because that increases the odds that a possible intruder will get at your potentially valuable data in the database. You might perhaps want to leave the database without a password for testing, but you should make sure that you do not forget to set a password after you are done with your tests. Retest to see whether everything works with the password in place. If you have created a password for the root database user (or if your distribution has done so for you — check your documentation in case of any problems), you must specify the -p option, which makes mysqladmin ask you for your password.
We should add here that most distributions include a startup script for the MySQL server that you can use instead of starting the server manually (especially if you have installed MySQL from your installation media). Often, this script is in /etc/init.d/mysql.
With the database server started and working, we can start to define database users and create new databases. We would like to point out that a usable tutorial is included with the MySQL sources. You can also find lots of documentation on http://www.mysql.com, so we just cover the very basics here to get you started.
Initial Tasks: Setting Up Users and SQL
There are three ways of communicating with the MySQL engine: you can use a console-based database client, you can write so-called SQL scripts and feed them to the database in order to execute many SQL commands at once, and you can use one of the many bindings