Ubuntu Server下启动/停止/重启MySQL数据库的三种方式
系统环境:ubuntu server 12.10 x64(mysql为系统自带)
当我们需要修改MySQL的配置文件my.cnf(windows 下为 my.ini)来进行一些设置的时候,修改完之后我们需要重启MySQL。
my.cnf文件位置为:/ect/mysql/my.cnf
Waring:如果该文件配置错误,MySQL将无法启动。
下面介绍三种方式对MySQL进行启动/停止/重启操作:
启动mysql:
方式一:sudo /etc/init.d/mysql start
方式二:sudo start mysql
方式三:sudo service mysql start
停止mysql:
方式一:sudo /etc/init.d/mysql stop
方式二:sudo stop mysql
方式san:sudo service mysql stop
重启mysql:
方式一:sudo/etc/init.d/mysql restart
方式二:sudo restart mysql
方式三:sudo service mysql restart
安装mysql
(1)在终端下执行sudo apt-get install mysql-server-5.6 命令
(2)一路按TAB键 回车键,等安装好之后,再设置密码。即可
(3)安装成功之后,执行mysql -u root命令,进入数据库,如下:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.27-0ubuntu1 (Ubuntu)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
设置mysql开机自启动
开机自动启动
sudo update-rc.d -f mysql.server defaults
开机禁止自动启动
sudo update-rc.d -f mysql.server remove