( Unix post-installation

Info Catalog ( Windows post-installation ( Post-installation ( Default privileges
 2.9.2 Unix Post-Installation Procedures


* mysql_install_db            Problems Running `mysql_install_db'
* Automatic start             Starting and Stopping MySQL Automatically
* Starting server             Starting and Troubleshooting the MySQL Server
 After installing MySQL on Unix, 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 and stops.  You should also
 assign passwords to the accounts in the grant tables.
 On Unix, the grant tables are set up by the `mysql_install_db' program.
 For some installation methods, this program is run for you
    * If you install MySQL on Linux using RPM distributions, the server
      RPM runs `mysql_install_db'.
    * If you install MySQL on Mac OS X using a PKG distribution, the
      installer runs `mysql_install_db'.
 Otherwise, you'll need to run `mysql_install_db' yourself.
 The following procedure describes how to initialize the grant tables (if
 that has not previously been done) and then start the server. It also
 suggests some commands that you can use to test whether the server is
 accessible and working properly.  For information about starting and
 stopping the server automatically, see  Automatic start.
 After you complete the procedure and have the server running, you should
 assign passwords to the accounts created by `mysql_install_db'.
 Instructions for doing so are given in  Default privileges.
 In the examples shown here, the server runs under the user ID of the
 `mysql' login account. This assumes that such an account exists.
 Either create the account if it does not exist, or substitute the name
 of a different existing login account that you plan to use for running
 the server.
   1. Change location into the top-level directory of your MySQL
      installation, represented here by BASEDIR:
           shell> cd BASEDIR
      BASEDIR is likely to be something like `/usr/local/mysql' or
      `/usr/local'.  The following steps assume that you are located in
      this directory.
   2. If necessary, run the `mysql_install_db' program to set up the
      initial MySQL grant tables containing the privileges that
      determine how users are allowed to connect to the server. You'll
      need to do this if you used a distribution type that doesn't run
      the program for you.
      Typically, `mysql_install_db' needs to be run only the first time
      you install MySQL, so you can skip this step if you are upgrading
      an existing installation, However, `mysql_install_db' does not
      overwrite any existing privilege tables, so it should be safe to
      run in any circumstances.
      To initialize the grant tables, use one of the following commands,
      depending on whether `mysql_install_db' is located in the `bin' or
      `scripts' directory:
           shell> bin/mysql_install_db --user=mysql
           shell> scripts/mysql_install_db --user=mysql
      The `mysql_install_db' script creates the data directory, the
      `mysql' database that holds all database privileges, and the `test'
      database that you can use to test MySQL. The script also creates
      privilege table entries for `root' accounts and anonymous-user
      accounts.  The accounts have no passwords initially.  A
      description of their initial privileges is given in  Default
      privileges.  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_'.
      It is important to make sure that the database directories and
      files are owned by the `mysql' login account so that the server
      has read and write access to them when you run it later. To ensure
      this, the `--user' option should be used as shown if you run
      `mysql_install_db' as `root'. Otherwise, you should execute the
      script while logged in as `mysql', in which case you can omit the
      `--user' option from the command.
      `mysql_install_db' creates several tables in the `mysql' database:
      `user', `db', `host', `tables_priv', `columns_priv', `func', and
      possibly others depending on your version of MySQL.
      If you don't want to have the `test' database, you can remove it
      with `mysqladmin -u root drop test' after starting the server.
      If you have problems with `mysql_install_db', see 
      `mysql_install_db' mysql_install_db.
      There are some alternatives to running the `mysql_install_db'
      script as it is provided in the MySQL distribution:
         * If you want the initial privileges to be different from the
           standard defaults, you can modify `mysql_install_db' before
           you run it.  However, a preferable technique is to use
           `GRANT' and `REVOKE' to change the privileges after the grant
           tables have been set up.  In other words, you can run
           `mysql_install_db', and then use `mysql -u root mysql' to
           connect to the server as the MySQL `root' user so that you
           can issue the `GRANT' and `REVOKE' statements.
           If you want to install MySQL on a lot of machines with the
           same privileges, you can put the `GRANT' and `REVOKE'
           statements in a file and execute the file as a script using
           `mysql' after running `mysql_install_db'. For example:
                shell> bin/mysql_install_db --user=mysql
                shell> bin/mysql -u root < your_script_file
           By doing this, you can avoid having to issue the statements
           manually on each machine.
         * It is possible to re-create the grant tables completely after
           they have previously been created.  You might want to do this
           if you're just learning how to use `GRANT' and `REVOKE' and
           have made so many modifications after running
           `mysql_install_db' that you want to wipe out the tables and
           start over.
           To re-create the grant tables, remove all the `.frm', `.MYI',
           and `.MYD' files in the directory containing the `mysql'
           database.  (This is the directory named `mysql' under the
           data directory, which is listed as the `datadir' value when
           you run `mysqld --help'.) Then run the `mysql_install_db'
           script again.
           * For MySQL versions older than 3.22.10, you should not
           delete the `.frm' files.  If you accidentally do this, you
           should copy them back into the `mysql' directory from your
           MySQL distribution before running `mysql_install_db'.
         * You can start `mysqld' manually using the
           `--skip-grant-tables' option and add the privilege
           information yourself using `mysql':
                shell> bin/mysqld_safe --user=mysql --skip-grant-tables &
                shell> bin/mysql mysql
           From `mysql', manually execute the SQL commands contained in
           `mysql_install_db'.  Make sure that you run `mysqladmin
           flush-privileges' or `mysqladmin reload' afterward to tell
           the server to reload the grant tables.
           Note that by not using `mysql_install_db', you not only have
           to populate the grant tables manually, you also have to
           create them first.
   3. Start the MySQL server:
           shell> bin/mysqld_safe --user=mysql &
      For versions of MySQL older than 4.0, substitute `bin/safe_mysqld'
      for `bin/mysqld_safe' in this command.
      It is important that the MySQL server be run using an unprivileged
      (non-`root') login account.  To ensure this, the `--user' option
      should be used as shown if you run `mysql_safe' as `root'.
      Otherwise, you should execute the script while logged in as
      `mysql', in which case you can omit the `--user' option from the
      Further instructions for running MySQL as an unprivileged user are
      given in  Changing MySQL user.
      If you neglected to create the grant tables before proceeding to
      this step, the following message will appear in the error log file
      when you start the server:
           mysqld: Can't find file: 'host.frm'
      If you have other problems starting the server, see  Starting
   4. Use `mysqladmin' to verify that the server is running.  The
      following commands provide simple tests to check whether the
      server is up and responding to connections:
           shell> bin/mysqladmin version
           shell> bin/mysqladmin variables
      The output from `mysqladmin version' varies slightly depending on
      your platform and version of MySQL, but should be similar to that
      shown here:
           shell> bin/mysqladmin version
           mysqladmin  Ver 8.40 Distrib 4.0.18, 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          4.0.18-log
           Protocol version        10
           Connection              Localhost via Unix socket
           TCP port                3306
           UNIX socket             /tmp/mysql.sock
           Uptime:                 16 sec
           Threads: 1  Questions: 9  Slow queries: 0
           Opens: 7  Flush tables: 2  Open tables: 0
           Queries per second avg: 0.000
           Memory in use: 132K  Max memory used: 16773K
      To see what else you can do with `mysqladmin', invoke it with the
      `--help' option.
   5. Verify that you can shut down the server: 
           shell> bin/mysqladmin -u root shutdown
   6. Verify that you can restart the server.  Do this by using
      `mysqld_safe' or by invoking `mysqld' directly.  For example:
           shell> bin/mysqld_safe --user=mysql --log &
      If `mysqld_safe' fails, see  Starting server.
   7. Run some simple tests to verify that you can retrieve information
      from the server.  The output should be similar to what is shown
           shell> bin/mysqlshow
           | Databases |
           | mysql     |
           | test      |
           shell> bin/mysqlshow mysql
           Database: mysql
           |    Tables    |
           | columns_priv |
           | db           |
           | func         |
           | host         |
           | tables_priv  |
           | user         |
           shell> bin/mysql -e "SELECT Host,Db,User FROM db" mysql
           | host | db     | user |
           | %    | test   |      |
           | %    | test_% |      |
   8. There is 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 benchmark suite is
      written in Perl. It uses the Perl DBI module to provide a
      database-independent interface to the various databases, and some
      other additional Perl modules are required to run the benchmark
      suite. You must have the following modules installed:
      These modules can be obtained from CPAN (`').
       Perl installation.
      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> perl run-all-tests
      If you don't have the `sql-bench' directory, you probably
      installed MySQL using RPM files other than the source RPM.  (The
      source RPM includes the `sql-bench' benchmark directory.)  In this
      case, you must first install the benchmark suite before you can
      use it.  Beginning with MySQL 3.22, there are separate benchmark
      RPM files named `mysql-bench-VERSION-i386.rpm' that contain
      benchmark code and data.
      If you have a source distribution, there are also tests in its
      `tests' subdirectory that you can run. For example, to run
      `auto_increment.tst', execute this command from the top-level
      directory of your source distribution:
           shell> mysql -vvf test < ./tests/auto_increment.tst
      The expected result of the test can be found in the
      `./tests/auto_increment.res' file.
   9. At this point, you should have the server running. However, none
      of the initial MySQL accounts have a password, so you should
      assign passwords using the instructions in  Default
 As of MySQL 4.1.3, the installation procedure creates time zone tables
 in the `mysql' database. However, you must populate the tables manually.
 Instructions to do this are given in  Time zone support.
Info Catalog ( Windows post-installation ( Post-installation ( Default privileges
automatically generated byinfo2html