MySQL Basic Configuration and Startup for Solaris 10

por | 30 enero, 2007

By: Mel Lester Jr. ([email protected])

Version 1.05 November 27, 2006

To start using the mysql bundled with Solaris 10, a number of post-install procedures need to be made by root. This configuration has been successfully tested in a Sparce Root Local Zone. The following steps are derived from the mysql manual (, manual.txt or manual_toc.html) found in the /usr/sfw/src/mysql/Docs directory.

  1. Log in as root and initialise the database tables.
        # /usr/sfw/bin/mysql_install_db
        Preparing db table
        Preparing host table
        Preparing user table
        Preparing func table
        Preparing tables_priv table
        Preparing columns_priv table
        Installing all prepared tables
        060118 21:24:03 /usr/sfw/sbin/mysqld: Shutdown Complete
  2. Create mysql user and group and change data directory group.
        # groupadd mysql
        # useradd -g mysql mysql
        # chgrp -R mysql /var/mysql
        # chmod -R 770 /var/mysql
        # installf SUNWmysqlr /var/mysql d 770 root mysql
  3. MySQL reads configuration files from different places in the following order:
        Filename                Purpose
        ---------               ---------
        /etc/my.cnf             Global options
        DATADIR/my.cnf          Server-specific options
        defaults-extra-file	    The file specified with --defaults-extra-file=path
        ~/.my.cnf               User-specific options
  4. Optionally copy a mysql daemon configuration file to configuration directory.

    Note: there are other configuration profiles available.
    For default solaris installation DATADIR is /var/mysql.

        # cp /usr/sfw/share/mysql/my-medium.cnf /var/mysql/my.cnf
  5. Start mysql daemon by hand
        # /usr/sfw/sbin/mysqld_safe --user=mysql &
  6. Set the root MySQL user password (Substitute a unique password for «new-password»)
        # cd /usr/sfw/bin

    Note the use of single quotes surrounding your new-password and the back ticks surrounding the hostname command — they are not the same!

        # ./mysqladmin -u root password 'new-password'
        # ./mysqladmin -u root -h `hostname` password 'new-password'
  7. Test the server:
        # ./mysqlshow -p
        Enter password: new-password
                 | Databases |
                 | mysql     |
                 | test      |
        # ./mysql -u root -p
        Enter password: new-password
                 Welcome to the MySQL monitor.  Commands end with ; or \g.
                 Your MySQL connection id is 3 to server version: 4.0.20-standard
                 Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
                 mysql> show databases;
                 | Databases |
                 | mysql     |
                 | test      |
                 2 rows in set (0.00 sec)
                 mysql> quit;
  8. Optionally perform the following steps for automatic start and stop of mysql daemon at boot and shutdown:

    Link boot time start up script from rc3.d and rc[012S].d

        # ln /etc/sfw/mysql/mysql.server /etc/rc3.d/S99mysql
        # ln /etc/sfw/mysql/mysql.server /etc/rc0.d/K00mysql
        # ln /etc/sfw/mysql/mysql.server /etc/rc1.d/K00mysql
        # ln /etc/sfw/mysql/mysql.server /etc/rc2.d/K00mysql
        # ln /etc/sfw/mysql/mysql.server /etc/rcS.d/K00mysql

That should get you started. I’ll deal with setting up mysql to run as a Solaris 10 service instead of relying on the legacy method in the near future.