 |

Once you've installed MySQL (from either a binary or source
distribution), you need to initialize the grant tables, start the server
and make sure that the server works okay. You may also wish to arrange
for the server to be started and stopped automatically when your system
starts up and shuts down.
Normally you install the grant tables and start the server like this:
shell> cd mysql_installation_directory
shell> ./bin/mysql_install_db
shell> ./bin/safe_mysqld &
Testing is most easily done from the top-level directory of the MySQL
distribution. For a binary distribution, this is your installation directory
(typically something like `/usr/local/mysql'). For a source
distribution, this is the main directory of your MySQL source tree.
In the commands shown below in this section and in the following
subsections, BINDIR is the path to the location in which programs
like mysqladmin and safe_mysqld are installed. For a
binary distribution, this is the `bin' directory within the
distribution. For a source distribution, BINDIR is probably
`/usr/local/bin', unless you specified an installation directory
other than `/usr/local' when you ran configure .
EXECDIR is the location in which the mysqld server is
installed. For a binary distribution, this is the same as
BINDIR . For a source distribution, EXECDIR is probably
`/usr/local/libexec'.
Testing is described in detail below:
-
If necessary, start the
mysqld server and set up the initial
MySQL grant tables containing the privileges that determine how
users are allowed to connect to the server. This is normally done with the
mysql_install_db script:
shell> scripts/mysql_install_db
Typically, mysql_install_db needs to be run only the first time you
install MySQL. Therefore, if you are upgrading an existing
installation, you can skip this step. (However, mysql_install_db is
quite safe to use and will not update any tables that already exist, so if
you are unsure what to do, you can always run mysql_install_db .)
mysql_install_db creates six tables (user , db ,
host , tables_priv , columns_priv and func ) in the
mysql database. A description of the initial privileges is given in
6.10 Droits initiaux. Briefly, these privileges allow the MySQL
root user to do anything, and allow anybody to create or use databases
with a name of 'test' or starting with 'test_' .
If you don't set up the grant tables, the following error will appear in the
log file when you start the server:
mysqld: Can't find file: 'host.frm'
The above may also happens with a binary MySQL distribution if you
don't start MySQL by executing exactly ./bin/safe_mysqld !
You might need to run mysql_install_db as root . However,
if you prefer, you can run the MySQL server as an unprivileged
(non-root ) user, provided that user can read and write files in
the database directory. Instructions for running MySQL as an
unprivileged user are given in Changing MySQL user.
If you have problems with mysql_install_db , see
mysql_install_db .
There are some alternatives to running the mysql_install_db
script as it is provided in the MySQL distribution:
-
You may want to edit
mysql_install_db before running it, to
change the initial privileges that are installed into the grant tables.
This is useful if you want to install MySQL on a lot of machines
with the same privileges. In this case you probably should need only to add
a few extra INSERT statements to the mysql.user and
mysql.db tables!
-
If you want to change things in the grant tables after installing them, you
can run
mysql_install_db , then use mysql -u root mysql to
connect to the grant tables as the MySQL root user and issue
SQL statements to modify the grant tables directly.
-
It is possible to recreate the grant tables completely after they have
already been created. You might want to do this if you've already installed
the tables but then want to recreate them after editing
mysql_install_db .
For more information about these alternatives, see 6.10 Droits initiaux.
-
Start the MySQL server like this:
shell> cd mysql_installation_directory
shell> bin/safe_mysqld &
If you have problems starting the server, see 4.15.2 Problèmes avec le serveur MySQL.
-
Use
mysqladmin to verify that the server is running. The following
commands provide a simple test to check that the server is up and responding
to connections:
shell> BINDIR/mysqladmin version
shell> BINDIR/mysqladmin variables
The output from mysqladmin version varies slightly depending on your
platform and version of MySQL, but should be similar to that shown
below:
shell> BINDIR/mysqladmin version
mysqladmin Ver 6.3 Distrib 3.22.9-beta, for pc-linux-gnu on i686
TCX Datakonsult AB, by Monty
Server version 3.22.9-beta
Protocol version 10
Connection Localhost via UNIX socket
TCP port 3306
UNIX socket /tmp/mysql.sock
Uptime: 16 sec
Running threads: 1 Questions: 20 Reloads: 2 Open tables: 3
To get a feeling for what else you can do with BINDIR/mysqladmin ,
invoke it with the --help option.
-
Verify that you can shut down the server:
shell> BINDIR/mysqladmin -u root shutdown
-
Verify that you can restart the server. Do this using
safe_mysqld or
by invoking mysqld directly. For example:
shell> BINDIR/safe_mysqld --log &
If safe_mysqld fails, try running it from the MySQL
installation directory (if you are not already there). If that doesn't work,
see 4.15.2 Problèmes avec le serveur MySQL.
-
Run some simple tests to verify that the server is working.
The output should be similar to what is shown below:
shell> BINDIR/mysqlshow
+-----------+
| Databases |
+-----------+
| mysql |
+-----------+
shell> BINDIR/mysqlshow mysql
Database: mysql
+--------------+
| Tables |
+--------------+
| columns_priv |
| db |
| func |
| host |
| tables_priv |
| user |
+--------------+
shell> BINDIR/mysql -e "select host,db,user from db" mysql
+------+--------+------+
| host | db | user |
+------+--------+------+
| % | test | |
| % | test_% | |
+------+--------+------+
There is also a benchmark suite in the `sql-bench' directory (under the
MySQL installation directory) that you can use to compare how
MySQL performs on different platforms. The `sql-bench/Results'
directory contains the results from many runs against different databases and
platforms. To run all tests, execute these commands:
shell> cd sql-bench
shell> run-all-tests
If you don't have the `sql-bench' directory, you are probably using an
RPM for a binary distribution. (Source distribution RPMs include the
benchmark directory.) In this case, you must first install the benchmark
suite before you can use it. Beginning with MySQL 3.22, there are
benchmark RPM files named `mysql-bench-VERSION-i386.rpm' that contain
benchmark code and data.
If you have a source distribution, you can also run the tests in the
`tests' subdirectory. For example, to run `auto_increment.tst', do
this:
shell> BINDIR/mysql -vvf test < ./tests/auto_increment.tst
The expected results are shown in the `./tests/auto_increment.res' file.
Sommaire:
|