Linux下使用相关命令可以直接启动mysql服务,下面由学习啦小编为大家整理了linux下mysql启动服务命令的相关知识,希望对大家有帮助!

linux的mysql启动服务命令

linux的mysql启动服务命令1:使用mysqld启动、关闭MySQL服务

mysqld是MySQL的守护进程,我们可以用mysqld来启动、关闭MySQL服务,关于mysqld, MySQL 5.6官方介绍资料如下所示:

mysqld, also known as MySQL Server, is the main program that does most of the work in a MySQL installation. MySQL Server manages access to the MySQL data directory that contains databases and tables. The data directory is also the default location for other information such as log files and status files.

When MySQL server starts, it listens for network connections from client programs and manages access to databases on behalf of those clients.

The mysqld program has many options that can be specified at startup. For a complete list of options, run this command:

shell> mysqld --verbose --help

MySQL Server also has a set of system variables that affect its operation as it runs. System variables can be set at server startup, and many of them can be changed at runtime to effect dynamic server reconfiguration. MySQL Server also has a set of status variables that provide information about its operation. You can monitor these status variables to access runtime performance characteristics.

如果MySQL是rpm方式安装的话,mysqld位于/usr/sbin下,如果MySQL是二进制安装的话,mysqld则位于bin目录下面。

[root@localhost ~]# whereis mysqld

mysqld: /usr/sbin/mysqld /usr/share/man/man8/mysqld.8.gz

[root@localhost ~]# /usr/sbin/mysqld stop

2016-06-27 14:52:54 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2016-06-27 14:52:54 9315 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2016-06-27 14:52:54 9315 [ERROR] Aborting

2016-06-27 14:52:54 9315 [Note] Binlog end

2016-06-27 14:52:54 9315 [Note] /usr/sbin/mysqld: Shutdown complete

[root@localhost ~]# /usr/sbin/mysqld start

2016-06-27 14:52:59 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2016-06-27 14:52:59 9316 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2016-06-27 14:52:59 9316 [ERROR] Aborting

2016-06-27 14:52:59 9316 [Note] Binlog end

2016-06-27 14:52:59 9316 [Note] /usr/sbin/mysqld: Shutdown complete

linux的mysql启动服务命令2:使用mysqld_safe启动、关闭MySQL服务

很多时候,人们会纠结mysqld与mysqld_safe的区别. 其实mysqld_safe是一个脚本,一个非常安全的启动、关闭MySQL服务的脚本。它实际上也是调用mysqld来启动、关闭MySQL服务。关于mysqld_safe,可以参考官方文档mysqld_safe — MySQL Server Startup Script

linux的mysql启动服务命令3:使用mysql.server启动、关闭MySQL服务

[root@localhost mysql]# ./mysql.server stop

Shutting down MySQL..[ OK ]

[root@localhost mysql]# ./mysql.server start

Starting MySQL..[ OK ]

[root@localhost mysql]#

mysql.server其实也是一个脚本,它通过调用msqld_safe来启动、关闭MySQL服务。部分脚本脚本如下

[root@localhost mysql]# more mysql.server

#!/bin/sh

# Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB

# This file is public domain and comes with NO WARRANTY of any kind

# MySQL daemon start/stop script.

# Usually this is put in /etc/init.d (at least on machines SYSV R4 based

# systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.

# When this is done the mysql server will be started when the machine is

# started and shut down when the systems goes down.

# Comments to support chkconfig on RedHat Linux

# chkconfig: 2345 64 36

# description: A very fast and reliable SQL database engine.

# Comments to support LSB init script conventions

### BEGIN INIT INFO

# Provides: mysql

# Required-Start: $local_fs $network $remote_fs

# Should-Start: ypbind nscd ldap ntpd xntpd

# Required-Stop: $local_fs $network $remote_fs

linux的mysql启动服务命令4:使用mysqld_multi启动、关闭MySQL服务

当服务器上运行了多个MySQL实例时,mysqld_multi是一个非常棒的管理MySQL服务器的工具。当然在使用前,你必须提前做配置

[root@localhost mysql]# /usr/bin/mysqld_multi stop 1

[root@localhost mysql]# /usr/bin/mysqld_multi start 1

mysqld_multi is designed to manage several mysqld processes that listen for connections on different Unix socket files and TCP/IP ports. It can start or stop servers, or report their current status.

mysqld_multi searches for groups named [mysqldN] in my.cnf (or in the file named by the --defaults-file option). N can be any positive integer. This number is referred to in the following discussion as the option group number, or GNR. Group numbers distinguish option groups from one another and are used as arguments tomysqld_multi to specify which servers you want to start, stop, or obtain a status report for. Options listed in these groups are the same that you would use in the[mysqld] group used for starting mysqld. (See, for example, Section 2.10.5, “Starting and Stopping MySQL Automatically”.) However, when using multiple servers, it is necessary that each one use its own value for options such as the Unix socket file and TCP/IP port number. For more information on which options must be unique per server in a multiple-server environment, see Section 5.6, “Running Multiple MySQL Instances on One Machine”.

linux的mysql启动服务命令5:使用service 启动、关闭MySQL服务

service mysql start

service mysql stop

service mysql restart

其实如果你对service比较熟悉的话,就会知道运行上面命令,其实是service命令去找/etc/init.d下的相关的mysql脚本去执行启动、关闭动作。

[root@DB-Server init.d]# ls my*

mysql mysql.server

[root@DB-Server init.d]#

linux的mysql启动服务命令6: 使用/etc/init.d/mysql启动、关闭MySQL服务。

如果你非常了解方法5,那么就多了这么一个启动数据库的方式。其实/etc/init.d/mysql也是一个脚本,它调用mysqld_safe脚本来启动MySQL服务。如下所示,你会看到相关代码

[root@DB-Server bin]# /etc/init.d/mysql start

Starting MySQL....[ OK ]

[root@DB-Server bin]# /etc/init.d/mysql stop

Shutting down MySQL..[ OK ]

[root@DB-Server bin]#

6:使用mysqladmin关闭数据库

mysqladmin是一个执行管理操作的客户程序,这个命令可以使用安全模式关闭数据库,但是不能启动数据库。当然它可以停止和启动MySQL replication on a slave server

[root@DB-Server bin]# /usr/bin/mysqladmin -u root -p shutdown

Enter password:

linux命令mysql启动,linux中mysql启动服务命令相关推荐

  1. 用Dockerfile构建MySQL镜像并实现容器启动过程中MySQL数据库系统的初始化

    前一段时间就在研究用Dockerfile构建MySQL镜像并实现容器启动过程中MySQL数据库系统的初始化,但被一些无关紧要的事儿给耽误了,经过查阅<dockerfile最佳实践>及MyS ...

  2. wamp mysql 没有启动,WAMP中mysql服务突然无法启动 解决方法

    wamp的mysql服务前两天还能用,今天突然不能无法启动了,原因可能是近期电脑强行关机,删除wamp\bin\mysql\mysql5.6.17\data目录下的ib_logfile0和ib_log ...

  3. linux下启动、添加或删除服务命令

    在Linux系统下,一个Services的启动.停止以及重启通常是通过/etc/init.d目录下的脚本来控制的.然而,在启动或改变运行级别时,是在/etc/rcX.d中来搜索脚本.其中X是运行级别的 ...

  4. wamp mysql服务无法启动_wamp中mysql无法启动怎么办

    wamp中mysql无法启动的解决办法:1.通过设置环境变量,开启MySQL服务:2.在启动wampserver之前把MySQL服务停掉:3.在my.ini中添加或修改"innodb_for ...

  5. 【Linux】大数据开发中常用的shell命令

    内容目录 一.date 二.find 三.awk 四.cut 五.if 六.sort 一.date 具体的用法如下: 显示当前日期和时间 date +%Y-%m-%d\ %H:%M:%S 将日期转换为 ...

  6. mysql for centos_CentOs中mysql的安装与配置

    这里我是通过yum来进行mysql数据库的安装的,通过这种方式进行安装,可以将跟mysql相关的一些服务和jar包都给我们安装好,比较方便. 一.查看系统中是否已经自带mysql数据库 可以看到运行r ...

  7. phpcms mysql 事务_PHPCMS中mysql数据库优化教程

    PHPCMS中mysql数据库优化教程 在全体的系统运转过程中,数据库服务器 MySQL 的压力是最大的,不只占用很多的内存和 cpu 资源,而且占用着大局部的磁盘 io 资源,连 PHP 的民间都在 ...

  8. 服务部署在linux上,将springcloud工程中的一个服务部署到linux服务器上

    将工程打包成jar包,使用xshell登录到linux服务器上 ip:192.168.0.129 port:22 用户名:root 密码:123456 将jar包上传到linux中 使用脚本rrk-s ...

  9. freebsd mysql 安装_Freebsd中mysql安装及使用笔记-阿里云开发者社区

    Freebsd中mysql安装及使用笔记 x3d 2009-07-31 662浏览量 简介: 1.安装 一开始连mysql的软件包在freebsd中叫什么都不知道: 依稀属于databases类,先到 ...

  10. 独立mysql安装,LAMP中mysql独立安装

    1,mysql下载官网下载mysql稳定版安装包到本地5.7(一般找次新版本即较稳定) 2,xshell连接服务器,进入目录src下(cd /usr/local/src),上传本地包到服务器(rz), ...

最新文章

  1. 老p7,来阿里快十年了,怎么着资产都上千万了,但是过的无比拮据
  2. 事件处理 ajax,AJAX的多事件处理机制
  3. 11-机器学习开发流程--初识
  4. 启动项目后,FileItemFactory 错误
  5. asp.Net Cookie demo
  6. linux终端下的网页浏览器w3m
  7. apulSoft apShaper for Mac(滤波失真插件)
  8. STC-ISP下载失败的原因小结
  9. bootstrap-入门学习-流体容器与响应式布局容器
  10. 数字转换英语c语言程序,C语言编写的英语数字转化代码(数字转化为用英语表达的数字).doc...
  11. R语言windows函数自动生成可视化图像画布框、使用plot函数可视化数据点图、使用type参数指定数据点为实线
  12. 哒螨灵使用注意事项_哒螨灵的使用方法
  13. 【DL】为什么需要深度学习:模组化、端到端学习(语音识别、图像处理情景)、类比逻辑电路
  14. EasyClass!Query类
  15. 网站降权后应该如何去处理
  16. 如何选择值得深入学习的技术方向
  17. harbor 下载地址(国内代理)
  18. ojdbc6中的错误信息(中英) 【转】
  19. 二叉树 | 二叉树的深度
  20. 动态时间规整算法: 从DTW到FastDTW

热门文章

  1. 局域网网站服务器dns设置,局域网设置dns的方法
  2. 高中计算机基础知识,高中计算机基础知识.ppt
  3. 【从零开始的OpenGL学习】1. 配置OpenGL,绘制最简单的一个三角形,HelloWorld(学习笔记)
  4. Windows 10上不使用MicroSoft Store下载安装MicroSoft Todo
  5. 邮箱总是被垃圾邮件轰炸?来试试这个临时邮箱生成器吧!
  6. 网络工程师考试知识点总结
  7. 管理者如何对待员工反馈
  8. Linux安装显卡驱动后闪屏问题
  9. Fedora 9 NFS配置
  10. lora与NB-IoT无线通讯技术在消防产品上的应用-lora烟感/NB烟感