OpenSolaris0811中使用tar.gz成功安装配置mysql

使用mysql安装文件mysql-5.0.67-solaris10-i386.tar.gz成功在OpenSolaris0811上安装


解压文件
dong@opensolaris:~/Download$ gtar xvf mysql-5.0.67-solaris10-i386.tar.gz

 

生成目录
dong@opensolaris:~/Download$ ls -l | grep mysql
drwxr-xr-x 14 dong staff        19 2008-08-04 21:40 mysql-5.0.67-solaris10-i386
-rwxr-xr-x  1 dong staff  56209790 2009-05-07 21:54 mysql-5.0.67-solaris10-i386.tar.gz


移动目录,我将mysql安装在/opt下
dong@opensolaris:~/Download$ pfexec mv mysql-5.0.67-solaris10-i386 /opt/mysql
dong@opensolaris:~/Download$ cd /opt/mysql


切换到root,懒得老是打pfexec
dong@opensolaris:/opt/mysql$ su
Password:
dong@opensolaris:/opt/mysql#


添加mysql用户组和用户,不过OpenSolaris0811貌似默认就有了,安全起见在跑一次
dong@opensolaris:/opt/mysql# groupadd mysql
UX: groupadd: ERROR: mysql is already in use.  Choose another.
dong@opensolaris:/opt/mysql# useradd -g mysql mysql
UX: useradd: ERROR: mysql is already in use.  Choose another.


转换mysql目录的所有权
dong@opensolaris:/opt/mysql# chown -R mysql .
dong@opensolaris:/opt/mysql# chgrp -R mysql .


运行mysql数据库安装脚本
dong@opensolaris:/opt/mysql# ./scripts/mysql_install_db --user=mysql


启动mysql数据库服务
dong@opensolaris:/opt/mysql# ./bin/mysqld_safe --user=mysql &


关闭mysql数据库服务
dong@opensolaris:/opt/mysql# ./bin/mysqladmin -u root shutdown


到此mysql安装完成,不过仍然存在不少问题

问题一:找不到mysql数据目录,因为mysql的默认安装目录是/usr/local/mysql

dong@opensolaris:/opt/mysql$ ./bin/mysqld_safe --user=mysql &
[1] 919
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /usr/local/mysql/data
./bin/mysqld_safe[380]: /usr/local/mysql/data/opensolaris.err: cannot create [No such file or directory]
./bin/mysqld_safe[388]: eval[1]: /usr/local/mysql/data/opensolaris.err: cannot create [No such file or directory]
STOPPING server from pid file /usr/local/mysql/data/opensolaris.pid
tee: /usr/local/mysql/data/opensolaris.err: No such file or directory
090513 23:17:14  mysqld ended
tee: /usr/local/mysql/data/opensolaris.err: No such file or directory

[1]+  Exit 1                  ./bin/mysqld_safe --user=mysql

解决方法:使用mysql的配置文件
support-files目录下自带了一些配置文件,我使用的是my-small.cnf,将它copy到/etc下,并重命名为my.cnf,配置一下mysqld_safe

dong@opensolaris:/opt/mysql/support-files# cp my-small.cnf /etc/my.cnf
在文件中增加mysqld_safe的配置
[mysqld_safe]
basedir=/opt/mysql
datadir=/opt/mysql/data

问题二:权限问题,除了root或者用pfexec外,其他用户不能启动服务

dong@opensolaris:/opt/mysql$ ./bin/mysqld_safe --user=mysql &
[1] 1081
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /opt/mysql/data
./bin/mysqld_safe[380]: /opt/mysql/data/opensolaris.err: cannot create [Permission denied]
rm: cannot remove `/opt/mysql/data/opensolaris.pid': Permission denied
./bin/mysqld_safe[388]: eval[1]: /opt/mysql/data/opensolaris.err: cannot create [Permission denied]
STOPPING server from pid file /opt/mysql/data/opensolaris.pid
tee: /opt/mysql/data/opensolaris.err: Permission denied
090513 23:34:01  mysqld ended
tee: /opt/mysql/data/opensolaris.err: Permission denied

发生这问题主要是因为data权限的问题,以下是我更改之前的权限
drwxr-x---  4 mysql mysql     8 2009-05-13 23:15 data

我的做法是更改目录权限,并为经常使用的用户添加mysql附属组
dong@opensolaris:/opt/mysql# chmod 770 data
dong@opensolaris:/opt/mysql# usermod -G "mysql" dong
UX: usermod: dong is currently logged in, some changes may not take effect until next login.
重新登录,并查看一下自己的信息
dong@opensolaris:~$ id -a
uid=101(dong) gid=10(staff) groups=10(staff),70(mysql)
dong@opensolaris:~$ cd /opt/mysql/
dong@opensolaris:/opt/mysql$ ./bin/mysqld_safe --user=mysql &
[1] 1215
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /opt/mysql/data

dong@opensolaris:/opt/mysql$ ps -ef | grep mysql
    dong  1215  1198   0 23:44:00 pts/2       0:00 /bin/sh ./bin/mysqld_safe --user=mysql
    dong  1239  1215   0 23:44:01 pts/2       0:01 /opt/mysql/bin/mysqld --basedir=/opt/mysql --datadir=/opt/mysql/data --pid-file
    dong  1245  1198   0 23:44:51 pts/2       0:00 grep mysql
正常启动,可以使用mysql工具连接测试一下
停止服务
dong@opensolaris:/opt/mysql$ ./bin/mysqladmin -u root shutdown

问题三:在其他目录下不能启动服务,必须在安装目录下才能启动

dong@opensolaris:~$ /opt/mysql/bin/mysqld_safe --user=mysql &
[1] 847
/opt/mysql/bin/mysqld_safe[199]: my_print_defaults: not found [No such file or directory]
/opt/mysql/bin/mysqld_safe[204]: my_print_defaults: not found [No such file or directory]
The file /usr/local/mysql/bin/mysqld doesn't exist or is not executable
Please do a cd to the mysql installation directory and restart
this script from there as follows:
./bin/mysqld_safe.
See [url]http://dev.mysql.com/doc/mysql/en/mysqld-safe.html[/url] for more
information

[1]+  Exit 1                  /opt/mysql/bin/mysqld_safe --user=mysql

my_print_defaults在/opt/mysql/bin下的,只要将/opt/mysql/bin配置到PATH中去,就不怕找不到了
另外如果不是在安装目录下运行mysqld_safe还要指定mysqld所在的目录,这里通过配置文件解决就可以了
在[mysqld_safe]多加一条ledir=/opt/mysql/bin,用来指定mysqld所在的目录

[mysqld_safe]
basedir=/opt/mysql
datadir=/opt/mysql/data
ledir=/opt/mysql/bin

ok,启动服务

dong@opensolaris:~$ /opt/mysql/bin/mysqld_safe --user=mysql &
[1] 1328
nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /opt/mysql/data

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值