就是按照官方的《MySQL5.1参考手册》2.7节“在其它类Unix系统中安装MySQL”步骤安装的,还是官方的资料可靠,自己稍微整理一下,方便查阅。

Unix:
$ uname -a
SunOS fs-cluster1 5.8 Generic_108528-13 sun4u sparc SUNW,Sun-Fire-280R

MySQL:
mysql-5.0.45-solaris8-sparc-64bit.tar.gz

一、为mysqld增加一个登录用户和组:

# groupadd mysql

# useradd -d /opt/mysql -g mysql -m mysql

二、挑选一个你想解开分发包的目录,进入该目录。在下面的例子中,我们将分发解包在“/usr/local”下:

# cd /usr/local

三、解包分发版,将创建安装目录。然后生成到该目录的一个符号链接:

# gunzip < /opt/mysql-5.0.45-solaris8-sparc-64bit.tar.gz | tar -xvf -

# ln -s mysql-5.0.45-solaris8-sparc-64bit mysql

四、进入安装目录:

# cd mysql

你会在mysql目录下发现几个文件和子目录,对安装目的最重要的是“bin”和“scripts”子目录。

·bin
这个目录包含客户端程序和服务器,你应该把这个目录的完整路径加到PATH环境变量,以便shell能正确的找到MySQL程序。

·scripts
这个目录包含mysql_install_db脚本,用来初始化mysql数据库的授权表,其中贮存了服务器访问允许。

五、如果还没有安装MySQL,必须创建MySQL授权表:

# scripts/mysql_install_db --user=mysql
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:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h fs-cluster1 password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./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 ./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/
#

如果你用root运行命令,应当使用--user选项。选项的值应与你在第一步为运行服务器所创建的登录账户相同。如果你用该用户登录来运行命令,可以省略--user选项。

六、将程序二进制的所有权改为root,数据目录的所有权改为运行mysqld 的用户:

# chown -R root .

# chown -R mysql data

# chgrp -R mysql .

第一个命令将文件的所有属性改为root用户。第二个命令将数据目录的所有属性改为mysql用户。第三个命令将组属性改为mysql组。

如果你喜欢在引导机器时自动启动MySQL,可以拷贝support-files/mysql.server文件到系统有启动文件的地方。

在所有东西被解包并且安装以后,你应该初始化并且测试你的分发版。

七、可以用下列命令启动MySQL服务器:

# bin/mysqld_safe --user=mysql &
[1] 13502
# Starting mysqld daemon with databases from /usr/local/mysql-5.0.45-solaris8-sparc-64bit/data

注释:MySQL授权表中的账户开始没有密码。启动服务器后,应当设置密码。

八、其它设置

把/usr/local/mysql/bin放入环境变量PATH里。

直接登陆:

# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.45 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

修改密码:

# mysqladmin -u root password 'root'

修改密码后登陆方式:

# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
# mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.45 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

九、数据库起停

使用mysqladmin验证服务器在运行中。以下命令提供了简单的测试,可检查服务器是否已经启动并能响应连接:

# mysqladmin -uroot -proot version
mysqladmin Ver 8.41 Distrib 5.0.45, for sun-solaris2.8 on sparc
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version 5.0.45
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 13 min 49 sec

Threads: 1 Questions: 9 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 0.011

关闭服务器:

# mysqladmin -uroot -proot shutdown

重启服务器:

# mysqld_safe --user=mysql &
[1] 13583
# Starting mysqld daemon with databases from /usr/local/mysql/data

--End--
posted on 2012-03-20 18:07  jdonson  阅读(2393)  评论(0编辑  收藏  举报