Thursday, November 28, 2013

MySQL Installation - Solaris 10

#vi .bash_profile
export PATH=$PATH:/usr/sfw/bin/:/opt/sfw/bin/:/opt/sfw/squid/$:/root/moshell:/usr/dt/bin:/opt/CTXSmf/bin:/opt/CTXSmf/sbin:/usr/apache2/bin:/etc/sfw/mysql

#pkginfo | grep -i mysql

system      SUNWmysqlr                       mysql - MySQL Database Management System (root component)
system      SUNWmysqlt                       mysql - MySQL Database Management System (test component)
system      SUNWmysqlu                       mysql - MySQL Database Management System (usr component)

We require two packages to be intalled to run our server.

1. SUMWmysqlr   The server component
2. SUMWmysqlu   The user component

We one more optional component 3. SUMWmysqlt - Which is for test purpose, and we wont cover that.

Install the mysql packages

#pkgadd -d SUNWmysqlr
#pkgadd -d SUNWmysqlu
#pkgadd -d SUNWmysqlt

To Check if the package is installed
# pkginfo -x | grep mysql
SUNWmysqlr                        mysql - MySQL Database Management System (root component)
SUNWmysqlt                        mysql - MySQL Database Management System (test component)
SUNWmysqlu                        mysql - MySQL Database Management System (usr component)

To know about the installed package
# pkginfo -l SUNWmysqlr
   PKGINST:  SUNWmysqlr
      NAME:  mysql - MySQL Database Management System (root component)
  CATEGORY:  system
      ARCH:  i386
   VERSION:  11.10.0,REV=2005.01.08.01.09
   BASEDIR:  /
    VENDOR:  Sun Microsystems, Inc.
      DESC:  mysql - MySQL Database Management System (root component) 4.0.31
    PSTAMP:  sfw10-patch-x20080616093045
  INSTDATE:  Jul 10 2011 10:50
   HOTLINE:  Please contact your local service provider
    STATUS:  completely installed
     FILES:        7 installed pathnames
                   3 shared pathnames
                   5 directories
                   1 executables
                  16 blocks used (approx)

To View the contents of the package
# pkgchk -v SUNWmysqlr
/etc
/etc/sfw
/etc/sfw/mysql
/etc/sfw/mysql/README.solaris.mysql
/etc/sfw/mysql/mysql.server
/var
/var/mysql

README.solaris.mysql  is important document here, make sure we go through it.

Now we initialize the Database.
# /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
110814 12:41:06 /usr/sfw/sbin/mysqld: Shutdown Complete

To start mysqld at boot time you have to copy /etc/sfw/mysql/mysql.server -  to the right place for your system.

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands:

#/usr/sfw/bin/mysqladmin -u root -h solaris-1 password 'daewoo'

See the manual for more instructions. You can start the MySQL daemon with:
#/usr/sfw/sbin/mysqld_safe &

You can test the MySQL daemon with the tests in the 'mysql-test' directory:
#cd /usr/sfw/mysql/mysql-test; ./mysql-test-run

Please report any problems with the /usr/sfw/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com - Support MySQL by buying support/licenses at http://shop.mysql.com

Next Step is to Populate
#installf SUNWmysqlr /var/mysql d 770 root mysql

We will be running the mysql service under user mysql. For that we will create the user mysql
#groupadd mysql
#useradd -g mysql mysql

Note : There is no need to set up password for mysql.  Since we wont log-in with mysql. we just need it to run
the process under mysql account.
#chgrp -R mysql /var/mysql/
#chmod -R 770 /var/mysql/

Next Step is to copy config file to /etc/my.cnf we will copy from the
#cp /usr/sfw/share/mysql/my-medium.cnf /etc/my.cnf

When starting the mysqld (daemon), it reads the my.cnf in the /etc

We will copy the configuration file from /usr/sfw/mysql/  There are various kind of configuration files
we have

my-medium.cnf
my-small.cnf
my-large.cnf
my-innodb-heavy-4G.cnf

Based on your requirement you could copy the file as /etc/my.cnf

MyISAM Storage engine creates following major data files in the mysql data directory normally /var/lib/mysql (exact you could find in the /etc/my.cnf)

File Extension     Purpose
.frm         table definition
.MYD         table data
.MYI         table indices

InnoDB Storage Engines create the following files for data storage.
.frm             Table structure
ibdata1        Default Data file.

Configure Mysql to start on reboot automatically

We have link the mysql.server to various runlevel start up scripts

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

To Start the SQL Server
#mysql.server start

Then Check the TCP port 3306 is LISTENING

#netstat -an | grep LISTEN

No comments: