Databases Reference
In-Depth Information
and stop the server with:
$
support-files/mysql.server stop
You can copy the
mysql.server
script and place it as the file
mysql
in the
/etc/init.d
directory:
#
cp support-files/mysql.server /etc/init.d/mysql
This allows you to control the server by typing:
#
/etc/init.d/mysql start
and
#
/etc/init.d/mysql stop
as with the package-based installation approaches. Importantly, this also allows you
to configure the server to start on every boot; this is explained later in “Configuring
MySQL for automatic start.”
Configuring a local server
With a local installation, the MySQL files will be placed in a directory under your home
directory, and the server will run under your username rather than
mysql
.
First, change to the directory containing the MySQL installation. If you followed our
instructions in “Installing MySQL on Linux by Compiling the Source Code from
MySQL AB,” you can type:
$
cd ~/mysql
To configure the data directory and initialize the database, you must run the
mysql_in
stall_db
script from the
scripts
directory:
$
scripts/mysql_install_db
If you want to use a data directory that's not under the MySQL installation directory,
you can specify the path using the
datadir
option, as in:
$
mysql_install_db datadir=
/home/adam/MySQL_Data
However, we'll assume you'll use the default data directory
~/mysql/data
.
Now you need to change the files in the MySQL directory to be owned by your username
and your group. For the username and group
adam
, you would write:
$ chown --recursive
adam:adam
~/mysql
Again, we described this use of the
chown
command earlier in “Restricting access to files
and directories.”
By default, MySQL listens for incoming client connections on port number 3306; if
there's already another server running on the same computer, you should choose a
different port number for this installation. It's best to avoid using port numbers that