Thursday, November 25, 2010

Installing MySQL on Solaris

1. Add mysql user id and group

# groupadd -g 300 mysql
# useradd -u 300 -g 300 -d /export/home/mysql -s /usr/bin/bash -c "MySQL DBA" mysql
# passwd mysql

2. Login as mysql

# su - mysql (or exec login mysql)

vi .bash_profile

PS1='$PWD: '
MYSQL_BASE=/usr/local/mysql
MYSQL_HOME=$MYSQL_BASE/5.1.42
export MYSQL_BASE MYSQL_HOME
PATH=$PATH:/usr/local/bin:/usr/bin:$MYSQL_HOME/bin
export PATH

3. Create the following base (parent) directory to download the MySQL software into.

# mkdir -p /usr/local/mysql
# export MYSQL_NAME=mysql01

The directory pattern of "mysql01" will be used to uniquely identify all physical files associated with
this specific MySQL database server.

4. Setup data directory structure

# mkdir -p /storage/db01/mysql/$MYSQL_NAME/data

5. Setup mysql administration directory structure
# mkdir -p /storage/db03/mysql/$MYSQL_NAME
# cd /storage/db03/mysql/$MYSQL_NAME/
# mkdir logs errors sql startup run


6. Setup binary log structure
# mkdir -p /storage/db02/mysql/$MYSQL_NAME/binlogs

7. Setup backup directory structure for backups and exports.
# mkdir -p /storage/db04/mysql/$MYSQL_NAME
# mkdir /storage/db04/mysql/$MYSQL_NAME/backups
# mkdir /storage/db04/mysql/$MYSQL_NAME/exports

8. Set permissions and ownership for MySQL file directories.
# chmod -R 750 /storage/db*/mysql/* /usr/local/mysql
# chown -R mysql:mysql /storage/db*/mysql/* /usr/local/mysql

9. Setup the MySQL software (as the MySQL OS user, not the root OS user)

$ cd /usr/local/mysql
$ /usr/local/bin/tar -xvzf ../packages/mysql-5.1.42-solaris10-sparc.tar.gz
$ ln -s mysql-5.1.42-solaris10-sparc 5.1.42
$ cp $MYSQL_HOME/support-files/my-small.cnf $MYSQL_HOME/my.cnf

10. Update my.cbf file

Add the following entries to the my.cnf file to the [mysqld] group.
This separates all your dynamic administration files, data files, and
binary log files to different locations. A separate port is defined away
from the default.


vi $MYSQL_HOME/my.cnf

[mysqld]
log-error=/storage/db03/mysql/mysql01/errors/mysql01.err
pid-file=/storage/db03/mysql/mysql01/mysql01.pid
datadir=/storage/db01/mysql/mysql01/data
basedir=/usr/local/mysql/5.1.42
log-bin=/storage/db02/mysql/mysql01/mysql-bin


11. Create the mysql database files for the MySQL instance. This will create
the default database schemas and database files.


$ cd $MYSQL_HOME
$ scripts/mysql_install_db --datadir=/storage/db01/mysql/mysql01/data --basedir=$MYSQL_HOME

Verify data files and directories have been created in the datadir directory.

$ cd /storage/db01/mysql/mysql01/data
$ ls

ib_logfile0 ib_logfile1 ibdata1 mysql test


12. Start the MySQL database server pointing to the defined locations.

$ cd /usr/local/mysql/5.1.24
$ bin/mysqld_safe --defaults-file=$MYSQL_HOME/my.cnf &


13. Updae passwords

# cd /usr/local/mysql/5.1.42

# ./bin/mysqladmin -u root -p password 'goodpass'
# ./bin/mysqladmin -u root -h localhost -p password 'goodpass'
# ./bin/mysqladmin -u root -h akash -p password 'goodpass'


$ cd $MYSQL_HOME
$ bin/mysql_secure_installation

Shutdown the MySQL server to verify you can shutdown and startup the MySQL instance.

$ mysqladmin --defaults-file=$MYSQL_HOME/my.cnf shutdown -uroot -p
$ cd $MYSQL_HOME

$ bin/mysqld_safe --defaults-file=$MYSQL_HOME/my.cnf

You're up and running have fun.

No comments:

Post a Comment