Monday, 3 November 2008

Setting up Blastwave's MySQL 5 on Solaris 10

I had to setup an instance of MySQL 5 on Solaris 10 update 4 and, given that it's not shipped with the OS, I relied on Blastwave's package. The package was really easy to install:

# /opt/csw/bin/pkg-get -i mysql5

Once the package was installed, I was please to see that a SMF manifest was also installed for it:

# svcs -a | grep mysql
offline 21:23:57 svc:/network/cswmysql5:default

An user and a group for the MySQL daemon were created, too:

$ cat /etc/passwd | grep mysql
mysql:x:109:103::/opt/csw/mysql5:/bin/false
$ cat /etc/group | grep mysql
mysql::103:

The first thing I did was examining the SMF methods script, which is declared in the service manifest and is /opt/csw/lib/svc/method/svc-mysql5. Because of Blastwave's packages quality level, I wasn't surprised to discover that the script is very well documented and getting MySQL to work was really straightforward.

First, I run the /opt/csw/mysql5/share/mysql/quick_start-csw script:

# /opt/csw/mysql5/share/mysql/quick_start-csw

This is the blastwave quick start script to setup a MySQL5 database directory.

The base directory is /opt/csw/mysql5.

The default database directory is /opt/csw/mysql5/var.


If you have not setup a partition for the database and

you want one; now is a good time to exit this script and

create and mount the partition.


If you have not setup a my.cnf file and you do not want
one of the sample files; now is a good time to exit and
create the file /opt/csw/mysql5/my.cnf.


Data directory: The default is /opt/csw/mysql5/var.

Accept the default or enter a directory [?,q]

my.cnf pathname: The default is either to use the supplied file in the base directory or to create one in the base directory from the small memory footprint sample. If your enter a pathname, it will be used to create the options file in the base directory.

Accept the default or enter a pathname [?,q]
Using /opt/csw/mysql5/share/mysql/my-small.cnf to create the options file.
data directory is /opt/csw/mysql5/var

Continue with installation or quit [y,n,?,q] y
Setting up the database
Creating MySQL core database in /opt/csw/mysql5/var

### The following messages are from mysql_install_db.
/opt/csw/mysql5/bin/mysql_install_db: !: not found
/opt/csw/mysql5/bin/mysql_install_db: !: not found
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy support-files/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:
/opt/csw/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/csw/mysql5/bin/mysqladmin -u root -h moneytrans-devel password 'new-password'

Alternatively you can run:
/opt/csw/mysql5/bin/mysql_secure_installation

which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd /opt/csw/mysql5 ; /opt/csw/mysql5/bin/mysqld_safe &


You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/csw/mysql5/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

### The following messages are from quick_start-csw.
See /opt/csw/mysql5/share/mysql/doc/README.CSW for packaging changes. Please ignore references to starting mysqld_safe in the messages above. These messages are from mysql_install_db. See the following for starting CSWmysql5. To start mysqld; run `svcadm enable cswmysql5` on Solaris 10 or later

After this, as the script's output informs us, I set up root password for the database and run the /opt/csw/mysql5/bin/mysql_secure_installation script to secure the database instance, the only caveat being setting up the PATH properly because this scripts expects to find the mysql program:

# export PATH=/opt/csw/mysql5/bin:$PATH
# /opt/csw/mysql5/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
... skipping.


By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] Y
... Success!


Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
... skipping.


By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.

Remove test database and access to it? [Y/n] Y
- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far will take effect immediately.

Reload privilege tables now? [Y/n] Y
... Success!


Cleaning up...

All done! If you've completed all of the above steps, your MySQL installation should now be secure.

Thanks for using MySQL!

Really easy! It started up and worked without a glitch. And if you want to customize your installation, as I already stated, I found good documentation right inside the very SMF script used by this service which can be found at /opt/csw/lib/svc/method/svc-mysql5.

No comments:

Post a Comment