On this post I’m going to describe all the steps to install MySQL 5.1 Community Server on last version 2009.06 of OpenSolaris.
First, we need to install the MySQL package :
DOWNLOAD PKGS FILES XFER (MB)
SUNWmysql51 0/2 0/335 0.00/84.19
Completed 2/2 335/335 84.19/84.19
PHASE ACTIONS
Install Phase 427/427
root@opensolaris:~#
NOTE : one alternative is to download directly the packages from MySQL website there and install it with pkgadd. It would also work on Solaris.
After the package installation, we can verify that
- a new SMF service is created :
disabled 14:12:23 svc:/application/database/mysql:version_51
root@opensolaris:~#
- a new mysql user and a new mysql group are added to the system :
mysql:x:70:70:MySQL Reserved UID:/:
root@opensolaris:~$ grep mysql /etc/group
mysql::70:
root@opensolaris:~$
- the /var/mysql/data directory is created, which will contains all the databases, log files, etc… :
root@opensolaris:/usr/mysql/bin#
- the mysql binaries are also there (of course !!!) :
64 mysql_install_db mysqldumpslow ndb_print_backup_file
amd64 mysql_secure_installation mysqlhotcopy ndb_print_schema_file
innochecksum mysql_setpermission mysqlimport ndb_print_sys_file
msql2mysql mysql_tzinfo_to_sql mysqlmanager ndb_restore
my_print_defaults mysql_upgrade mysqlshow ndb_select_all
myisam_ftdump mysql_waitpid mysqlslap ndb_select_count
myisamchk mysql_zap mysqltest ndb_show_tables
myisamlog mysqlaccess ndb_config ndb_size.pl
myisampack mysqladmin ndb_cpcd ndb_test_platform
mysql mysqlbinlog ndb_delete_all ndb_waiter
mysql_client_test mysqlbug ndb_desc ndbd
mysql_config mysqlcheck ndb_drop_index perror
mysql_convert_table_format mysqld ndb_drop_table replace
mysql_find_rows mysqld_multi ndb_error_reporter resolve_stack_dump
mysql_fix_extensions mysqld_safe ndb_mgm resolveip
mysql_fix_privilege_tables mysqldump ndb_mgmd
root@opensolaris:/usr/mysql/bin#
Next step is to populate the data directory with the mysql database, the unsusefull and unsecure test database… :
Installing MySQL system tables…
090925 16:20:47 [Warning] option ‘thread_stack’: unsigned value 65536 adjusted to 131072
090925 16:20:47 [Warning] option ‘thread_stack’: unsigned value 65536 adjusted to 131072
OK
Filling help tables…
090925 16:20:47 [Warning] option ‘thread_stack’: unsigned value 65536 adjusted to 131072
090925 16:20:47 [Warning] option ‘thread_stack’: unsigned value 65536 adjusted to 131072
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:
/usr/mysql/5.1/bin/mysqladmin -u root password ‘new-password’
/usr/mysql/5.1/bin/mysqladmin -u root -h opensolaris password ‘new-password’
Alternatively you can run:
/usr/mysql/5.1/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 /usr/mysql/5.1 ; /usr/mysql/5.1/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql/5.1/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/mysql/5.1/bin/mysqlbug script!
The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/
root@opensolaris:/usr/mysql/bin#
Let’s verify that the databases have been successfully created and the service is enabled :
total 4
drwx—— 2 mysql root 71 2009-09-25 16:20 mysql
drwx—— 2 mysql root 2 2009-09-25 16:20 test
root@opensolaris:/usr/mysql/bin#
root@opensolaris:/usr/mysql/bin# svcs mysql
STATE STIME FMRI
disabled 14:12:23 svc:/application/database/mysql:version_51
root@opensolaris:/usr/mysql/bin# svcadm enable mysql
root@opensolaris:/usr/mysql/bin#
root@opensolaris:/usr/mysql/bin# svcs -p mysql
STATE STIME FMRI
online 16:22:16 svc:/application/database/mysql:version_51
16:22:16 1810 mysqld_safe
16:22:19 1910 mysqld
root@opensolaris:/usr/mysql/bin#
root@opensolaris:/usr/mysql/bin# ps -fu mysql
UID PID PPID C STIME TTY TIME CMD
mysql 1810 1 0 16:22:17 ? 0:00 /bin/sh /usr/mysql/5.1/bin/mysqld_safe –user=mysql –datadir=/var/mysql/5.1/da
mysql 1910 1810 0 16:22:19 ? 0:01 /usr/mysql/5.1/bin/mysqld –basedir=/usr/mysql/5.1 –datadir=/var/mysql/5.1/dat
root@opensolaris:/usr/mysql/bin#
root@opensolaris:/usr/mysql/bin# pargs -l 1910
/usr/mysql/5.1/bin/mysqld ‘–basedir=/usr/mysql/5.1′ ‘–datadir=/var/mysql/5.1/data’ ‘–log-error=/var/mysql/5.1/data/opensolaris.err’ ‘–pid-file=/var/mysql/5.1/data/opensolaris.pid’ ‘–socket=/tmp/mysql.sock’ ‘–port=3306′
root@opensolaris:/usr/mysql/bin#
Finally, as the previous script told, we have to set a password for the MySQL root user.
An easy way to do that is to run the mysql_secure_installation script which will also ask us to remove anonymous users, delete the unsecure test database, etc… :
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.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!
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]
… 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]
… Success!
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]
- 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]
… 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!
root@opensolaris:/usr/mysql/bin#
Let’s verify that our MySQL server is now working well :
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.1.30 Source distribution
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> show databases;
+————————–+
| Database|
+————————–+
| information_schema |
| mysql |
+————————–+
2 rows in set (0.02 sec)
mysql>
mysql> select user,password,host from mysql.user;
+——+——————————————-+———–+
| user | password | host |
+——+——————————————-+———–+
| root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | localhost |
+——+——————————————-+———–+
1 row in set (0.01 sec)
mysql>
Arnaud
Sphere: Related ContentNo related posts.
Related posts brought to you by Yet Another Related Posts Plugin.

Core Networks homepage
Opensolaris
#1 by John P on March 23, 2010 - 05:54
Thanks for the writeup! One gotcha is that you need to be sure to do these steps after you “su root” and not via “pfexec ./mysql_install_db –-user=mysql” The latter will fail with “/usr/mysql/5.1/bin/mysqld: Too many arguments (first extra is ‘–-user=mysql’)”…
to recover, remove the /var/mysql/5.1/data directory, su root and rerun mysql_install_db …