Ubuntu15.10操作mysql5.6数据库

本文详细介绍了在Ubuntu Server环境下通过三种方式启动、停止和重启MySQL数据库,包括使用`sudo/etc/init.d/mysqlstart`、`sudostartmysql`和`sudoservicemysqlstart`等命令,以及如何在系统启动时自动加载MySQL服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一缕阳光直射你的心扉

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值