配置Solaris自带的Mysql

Installing MySql on Solaris 10


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.ps, 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/local/mysql/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/local/mysql/bin/mysqld: Shutdown Complete

2. Create mysql user and group and change data directory group.建立mysql用户和配置文件目录
# groupadd mysql
# useradd -g mysql mysql
# chgrp -R mysql /var/mysql
# chmod -R 770 /var/mysql
# installf SUNWmysqlr /var/mysql d 770 root mysql
# chown -R mysql:mysql /usr/local/mysql/var (critical step or you may end up with “[1] Exit 127″
(This took me a while to figure out, this directory is where the database is stored. Good to know if you want to back up)

/usr/local/bin/mysqld_safe –user=mysql
# Starting mysqld daemon with databases from /usr/local/mysql/var
STOPPING server from pid file /usr/local/mysql/var/tsai86.pid
070902 23:39:39 mysqld ended

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/local/mysql/share/mysql/my-medium.cnf /var/mysql/my.cnf

5. Start mysql daemon as mysql user manually 启动
/usr/local/mysql/bin/mysqld_safe –user=mysql &

6. Set the root MySQL user password (Substitute a unique password for “new-password”)
设置密码
# cd /usr/local/mysql/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;

+——————–+
| Database
|
+——————–+
| information_schema |
| mysql |
| test |
+——————–+
3 rows in set (0.00 sec)
8. mysql> quit;
Bye

9. Optionally perform the following steps for automatic start and stop of mysql daemon at boot and shutdown: (This doesn’t quite work for me and I haven’t figured out how to use the svc service to do this automatically.) Stay tuned…设置自动配合开关服务器。
Link boot time start up script from rc3.d and rc[012S].d
# ln /usr/local/mysql/share/mysql/mysql.server /etc/rc3.d/S99mysql
# ln /usr/local/mysql/share/mysql/mysql.server /etc/rc0.d/K00mysql
# ln /usr/local/mysql/share/mysql/mysql.server /etc/rc1.d/K00mysql
# ln /usr/local/mysql/share/mysql/mysql.server /etc/rc2.d/K00mysql
# ln /usr/local/mysql/share/mysql/mysql.server /etc/rcS.d/K00mysql

posted @ 2008-04-22 09:37  荖K  阅读(893)  评论(0编辑  收藏  举报