Databases Reference
In-Depth Information
root
account but is similar in that it has all privileges on the MySQL server. Let's look
at three situations:
• You've installed the server using RPM or Debian packages.
• You've installed a system-wide server using a tarball or by compiling source code.
• You've installed a local server to run under your own account using a tarball or by
compiling source code.
As we explained earlier, the XAMPP package is tightly integrated and is not designed
for easy modification, so we won't explore how to customize an XAMPP installation.
Configuring a server installed using RPM or Debian packages
The package installation process generally places the MySQL program files in the
/usr/
bin
directory, the datafiles in the
/var/lib/mysql
directory, and the server logs in
the
/var/log/mysqld
directory or the
/var/log/mysqld.log
file.
The installation typically configures the files and directories securely and also creates
the
/etc/init.d/mysql
or
/etc/init.d/mysqld
(MySQL daemon) startup script for easy con-
trol of the server.
Check what this script is called on your system using the
ls
command:
$
ls /etc/init.d/mysql*
/etc/init.d/mysql
In the preceding example, the file is called
mysql
. Use the appropriate name (
mysql
or
mysqld
) where you see
mysql
in the commands below.
To start the server, run the following command:
#
/etc/init.d/
mysql
start
Set a password for the database
root
account:
$
mysqladmin --user=root password
the_new_mysql_root_password
You can stop the server by typing the command:
#
/etc/init.d/
mysql
stop
The package-based installation process generally starts the MySQL server, and config-
ures it to be started automatically each time the system is started. In “Configuring
MySQL for automatic start,” later in this chapter, we explain how to check and con-
figure automatic startup.
Configuring a system-wide server installed from tarball or source
For security reasons, it's a good idea to have the system-wide MySQL server run under
its own username and group, rather than the superuser account. First, log in as the root
user with the
su -
command, and then create the
mysql
user group:
#
groupadd mysql