Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4028352
  • 博文数量: 626
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 11080
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-23 13:08
文章分类

全部博文(626)

文章存档

2015年(72)

2014年(48)

2013年(506)

分类: Mysql/postgreSQL

2015-10-28 15:50:26

MySQL在Ubuntu系统的三种自启动方法

1、、软件环境:

  1. Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-32-generic x86_64)
  2. MySQL 5.6.27 x64

2、方法一

最简单的方法是执行命令:

# update-rc.d mysql defaults
 Adding system startup for /etc/init.d/mysql ...
   /etc/rc0.d/K20mysql -> ../init.d/mysql
   /etc/rc1.d/K20mysql -> ../init.d/mysql
   /etc/rc6.d/K20mysql -> ../init.d/mysql
   /etc/rc2.d/S20mysql -> ../init.d/mysql
   /etc/rc3.d/S20mysql -> ../init.d/mysql
   /etc/rc4.d/S20mysql -> ../init.d/mysql
   /etc/rc5.d/S20mysql -> ../init.d/mysql 

注意:移除MySQL的开机服务可执行命令update-rc.d mysql remove

3、方法二

第二种方法是使用sysv-rc-conf工具,执行命令:

# apt-get install sysv-rc-conf
# sysv-rc-conf 

打开了命令行方式的自启动服务管理界面: 

用鼠标点击,也可以用键盘方向键定位,用空格键选择, “X”表示开启该服务。用Ctrl+N翻下一页,用Ctrl+P翻上一页,用Q退出。

也可以用命令:

# sysv-rc-conf --level 2345 mysql off 

注意:Ubuntu系统中服务的运行级别

0        系统停机状态
1        单用户或系统维护状态
2~5      多用户状态
6        重新启动 

4、方法三

第三种方法是使用chkconfig工具,执行命令:

# apt-get install chkconfig
# chkconfig mysql --list
mysql           0:off   1:off   2:off   3:off   4:off   5:off   6:off 

如果mysqld没有在列表,那么用命令添加它:

# chkconfig add mysql 

我们可以看到,mysqld本来就在列表中,所以这一步我们跳过。

使用命令设置开机启动:

# chkconfig --add mysql
# chkconfig mysql --list
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off 

表示MySQL的开机自启动已经设置完成。

阅读(3895) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~