当前位置: 技术问答>linux和unix
如何让mysql自动启动?
来源: 互联网 发布时间:2015-09-03
本文导语: 发表于: 2005-01-19 12:41 发表主题: 如何让mysql自动启动? -------------------------------------------------------------------------------- 在sun solaris下安装mysql,一切正确,现在想让其开机就启动, 查了不少文章,...
发表于: 2005-01-19 12:41 发表主题: 如何让mysql自动启动?
--------------------------------------------------------------------------------
在sun solaris下安装mysql,一切正确,现在想让其开机就启动,
查了不少文章,都说
加入在rc.local文件加入/usr/local/bin/safe_mysqld & 中以启动服务器。
但是我没有找到rc.local文件,
请教各位,我应该怎么做呢??
/etc>ls rc*
rc0 rc1 rc2 rc3 rc5 rc6 rcS
rc0.d:
K00ANNOUNCE K07snmpdx K28kdc.master K34svm.sync K39lp K40syslog K41rpc K62lu
K03samba K10dtlogin K28nfs.server K35atria K39spc K40xntpd K42inetsvc K68picld
K03sshd K16apache K33audit K36sendmail K40cron K41autofs K42sckm K83devfsadm
K05volmgt K21dhcp K33efcode K36utmpd K40nscd K41directory K43inet K90dhcpagent
K06mipagent K27boot.server K34IIim K36wbem K40sf880dr K41ldap.client K50pppd
K07dmi K28kdc K34ncalogd K37power K40slpd K41nfs.client K52llc2
rc1.d:
K00ANNOUNCE K07snmpdx K28kdc.master K34svm.sync K39spc K40xntpd K42sckm
K03samba K10dtlogin K28nfs.server K36sendmail K40cron K41autofs K43inet
K03sshd K16apache K33audit K36utmpd K40nscd K41directory K50pppd
K05volmgt K21dhcp K33efcode K36wbem K40sf880dr K41ldap.client K52llc2
K06mipagent K27boot.server K34IIim K37power K40slpd K41rpc S01MOUNTFSYS
K07dmi K28kdc K34ncalogd K39lp K40syslog K42inetsvc S10lu
rc2.d:
K03samba K28nfs.server S69inet S73nfs.client S80spc S94ncalogd
K03sshd README S70sckm S74autofs S85power S95IIim
K05volmgt S01MOUNTFSYS S70uucp S74syslog S88sendmail S95svm.sync
K06mipagent S05RMTMPFILES S71ldap.client S74xntpd S88utmpd S98efcode
K07dmi S10lu S71rpc S75cron S89PRESERVE S99audit
K07snmpdx S20sysetup S71sysid.sys S75flashprom S89bdconfig S99dtlogin
K16apache S21perf S72autoinstall S75savecore S90wbem
K21dhcp S30sysid.net S72directory S76nscd S91afbinit
K27boot.server S40llc2 S72inetsvc S77atria S91gfbinit
K28kdc S42ncakmod S72slpd S77sf880dr S91ifbinit
K28kdc.master S47pppd S73cachefs.daemon S80lp S93cacheos.finish
rc3.d:
DISABLED_S76snmpdx S10run_sadc S15nfs.server S50apache S89sshd
DISABLED_S77dmi S13kdc.master S16boot.server S80mipagent S90samba
README S14kdc S34dhcp S81volmgt S99prtdiag
rcS.d:
K03samba K27boot.server K36sendmail K40slpd K43inet S33keymap.sh
K03sshd K28kdc K36utmpd K40syslog K44wrsmcfg S35cacheos.sh
K05volmgt K28kdc.master K36wbem K40xntpd K50pppd S35svm.init
K06mipagent K28nfs.server K37power K41autofs K52llc2 S40standardmounts.sh
K07dmi K33audit K39lp K41directory README S41cachefs.root
K07snmpdx K33efcode K39spc K41ldap.client S10cvc S42coreadm
K10dtlogin K34IIim K40cron K41rpc S29wrsmcfg S50devfsadm
K16apache K34ncalogd K40nscd K42inetsvc S30network.sh S70buildmnttab.sh
K21dhcp K34svm.sync K40sf880dr K42sckm S30rootusr.sh S95picld
rcm:
scripts
--------------------------------------------------------------------------------
在sun solaris下安装mysql,一切正确,现在想让其开机就启动,
查了不少文章,都说
加入在rc.local文件加入/usr/local/bin/safe_mysqld & 中以启动服务器。
但是我没有找到rc.local文件,
请教各位,我应该怎么做呢??
/etc>ls rc*
rc0 rc1 rc2 rc3 rc5 rc6 rcS
rc0.d:
K00ANNOUNCE K07snmpdx K28kdc.master K34svm.sync K39lp K40syslog K41rpc K62lu
K03samba K10dtlogin K28nfs.server K35atria K39spc K40xntpd K42inetsvc K68picld
K03sshd K16apache K33audit K36sendmail K40cron K41autofs K42sckm K83devfsadm
K05volmgt K21dhcp K33efcode K36utmpd K40nscd K41directory K43inet K90dhcpagent
K06mipagent K27boot.server K34IIim K36wbem K40sf880dr K41ldap.client K50pppd
K07dmi K28kdc K34ncalogd K37power K40slpd K41nfs.client K52llc2
rc1.d:
K00ANNOUNCE K07snmpdx K28kdc.master K34svm.sync K39spc K40xntpd K42sckm
K03samba K10dtlogin K28nfs.server K36sendmail K40cron K41autofs K43inet
K03sshd K16apache K33audit K36utmpd K40nscd K41directory K50pppd
K05volmgt K21dhcp K33efcode K36wbem K40sf880dr K41ldap.client K52llc2
K06mipagent K27boot.server K34IIim K37power K40slpd K41rpc S01MOUNTFSYS
K07dmi K28kdc K34ncalogd K39lp K40syslog K42inetsvc S10lu
rc2.d:
K03samba K28nfs.server S69inet S73nfs.client S80spc S94ncalogd
K03sshd README S70sckm S74autofs S85power S95IIim
K05volmgt S01MOUNTFSYS S70uucp S74syslog S88sendmail S95svm.sync
K06mipagent S05RMTMPFILES S71ldap.client S74xntpd S88utmpd S98efcode
K07dmi S10lu S71rpc S75cron S89PRESERVE S99audit
K07snmpdx S20sysetup S71sysid.sys S75flashprom S89bdconfig S99dtlogin
K16apache S21perf S72autoinstall S75savecore S90wbem
K21dhcp S30sysid.net S72directory S76nscd S91afbinit
K27boot.server S40llc2 S72inetsvc S77atria S91gfbinit
K28kdc S42ncakmod S72slpd S77sf880dr S91ifbinit
K28kdc.master S47pppd S73cachefs.daemon S80lp S93cacheos.finish
rc3.d:
DISABLED_S76snmpdx S10run_sadc S15nfs.server S50apache S89sshd
DISABLED_S77dmi S13kdc.master S16boot.server S80mipagent S90samba
README S14kdc S34dhcp S81volmgt S99prtdiag
rcS.d:
K03samba K27boot.server K36sendmail K40slpd K43inet S33keymap.sh
K03sshd K28kdc K36utmpd K40syslog K44wrsmcfg S35cacheos.sh
K05volmgt K28kdc.master K36wbem K40xntpd K50pppd S35svm.init
K06mipagent K28nfs.server K37power K41autofs K52llc2 S40standardmounts.sh
K07dmi K33audit K39lp K41directory README S41cachefs.root
K07snmpdx K33efcode K39spc K41ldap.client S10cvc S42coreadm
K10dtlogin K34IIim K40cron K41rpc S29wrsmcfg S50devfsadm
K16apache K34ncalogd K40nscd K42inetsvc S30network.sh S70buildmnttab.sh
K21dhcp K34svm.sync K40sf880dr K42sckm S30rootusr.sh S95picld
rcm:
scripts
|
solaris 启动时会在/etc/rc2.d和/etc/rc3.d目录下寻找以“S”开头的文件并执行
所以只要在/etc/rc2.d 目录中创建一个启动脚本,并且以“S”开头(大写)数字表示是该脚本启动的顺序号。
cd /etc/rc2.d
vi S60mysqld
写入以下内容
#!/bin/bash
/usr/local/bin/safe_mysqld --user-mysql &
保存退出
reboot
这一点和LINUX不太一样,LINUX下多了一个rc.local,不过同样也是在/etc/rc2.d目录下有一个/etc/rc.local的连接,只是为了管理方便而已。
所以只要在/etc/rc2.d 目录中创建一个启动脚本,并且以“S”开头(大写)数字表示是该脚本启动的顺序号。
cd /etc/rc2.d
vi S60mysqld
写入以下内容
#!/bin/bash
/usr/local/bin/safe_mysqld --user-mysql &
保存退出
reboot
这一点和LINUX不太一样,LINUX下多了一个rc.local,不过同样也是在/etc/rc2.d目录下有一个/etc/rc.local的连接,只是为了管理方便而已。
|
2)编译、安装mysql
# groupadd mysql
# useradd -g mysql mysql
# cd /wbh
# gunzip mysql-4.0.15a.tar.gz
# tar xvf mysql-4.0.15a.tar
# cd mysql-4.0.15a
# ./configure --prefix=/usr/local/mysql
# make
# make install
# scripts/mysql_install_db
# chown -R root /usr/local/mysql
# chown -R mysql /usr/local/mysql/var
# chgrp -R mysql /usr/local/mysql
# cp support-files/my-medium.cnf /etc/my.cnf
3)启动mysql
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
# ps
PID TTY TIME CMD
334 pts/1 0:00 mysqld_s
如果看到类似的信息,说明mysql已经正常启动了
4)设置mysql启动脚本
# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
# ln -s /etc/init.d/mysqld /etc/rc2.d/Kmysqld
# ln -s /etc/init.d/mysqld /etc/rc2.d/Smysqld
这就是在Soalris下安装mysql的步骤
# groupadd mysql
# useradd -g mysql mysql
# cd /wbh
# gunzip mysql-4.0.15a.tar.gz
# tar xvf mysql-4.0.15a.tar
# cd mysql-4.0.15a
# ./configure --prefix=/usr/local/mysql
# make
# make install
# scripts/mysql_install_db
# chown -R root /usr/local/mysql
# chown -R mysql /usr/local/mysql/var
# chgrp -R mysql /usr/local/mysql
# cp support-files/my-medium.cnf /etc/my.cnf
3)启动mysql
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
# ps
PID TTY TIME CMD
334 pts/1 0:00 mysqld_s
如果看到类似的信息,说明mysql已经正常启动了
4)设置mysql启动脚本
# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
# ln -s /etc/init.d/mysqld /etc/rc2.d/Kmysqld
# ln -s /etc/init.d/mysqld /etc/rc2.d/Smysqld
这就是在Soalris下安装mysql的步骤