linux命令mysql启动,linux中mysql启动服务命令

linux命令mysql启动,linux中mysql启动服务命令Linux下使用相关命令可以直接启动mysql服务,下面由学习啦小编为大家整理了linux下mysql启动服务命令的相关知识,希望对大家有帮助!linux的mysql启动服务命令linux的mysql启动服务命令1:使用mysqld启动、关闭MySQL服务mysqld是MySQL的守护进程,我们可以用mysqld来启动、关闭MySQL服务,关于mysqld,MySQL5.6官方介绍资料如下所示…

大家好,又见面了,我是你们的朋友全栈君。

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:

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/143788.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • ROS创建Web代理(Web proxy)「建议收藏」

    ROS创建Web代理(Web proxy)「建议收藏」使用Web代理可以提高网页的访问速度,因为访问的数据会存储在内存或是硬盘中,就会直接从代理服务器中读取。同时,为了提高网络访问的安全性,可以给Web代理服务器设置相应的权限,使它的安全性得到提高。下面就介绍如何在RouterOS中创建Web代理的方法。一、启用Web-Proxy启用路径:IP/Web-Proxy,然后点击WebProx…

    2022年6月21日
    94
  • python3、sqlmap下载与安装教程

    一、前提需要安装python3,可以参考其他教程二、下载官网下载http://sqlmap.org/三、安装将下载的sqlmap.zip解压到文件夹sqlmap中,并拷贝到Python安装路径下四、配置在桌面上创建一个cmd进入python的快捷方式(这步可以不做,只是比较方便启动),右键新建快捷方式输入cmd快捷方式命名可随意,不作要求,这里用sqlmap右键–属性修改起始位置为sqlmap文件夹路径测试启动sqlmap,双击刚才创建的快捷方式,

    2022年4月7日
    240
  • spss系统聚类分析报告_社会分析数据分析

    spss系统聚类分析报告_社会分析数据分析介绍聚类分析的原理和各种聚类方法的选择和使用

    2022年10月7日
    3
  • avc中质量和大小是什么意思_avc设备是什么意思

    avc中质量和大小是什么意思_avc设备是什么意思avc在微观经济学意为:平均可变成本(averagevariablecost,avc)短期平均成本又可分为平均固定成本(averagefixedcost)和平均可变成本(averagevariablecost).电力行业的AVC系统是做什么的?AVC就是自动电压控制,就是大家常说的“无功优化”,实际上就是因为电压和无功是不可分割相互影响的。AVC和“无功优化”的实际意义有偏差,因为…

    2026年1月23日
    6
  • git clone下来的代码放在哪里,如何放在指定路径

    git clone下来的代码放在哪里,如何放在指定路径今天从github上clone了代码,最后出来形如:但是话说我的东西下载到哪里去了呢????摸不着头脑,然后百度之,发现一般会放在命令行对应的路径下,也就是win+R>cmd查看命令行地址:然后去此路径下寻找之,果然在这里。那么,如何才能clone到自己指定的路径下呢?百度之得如下说法:gitclonehttps://github.com/jque…

    2022年7月21日
    48
  • AD域控制器时间同步[通俗易懂]

    AD域控制器时间同步[通俗易懂]域控制器时间同步现象:域控制器和域内的计算机时间与internet上的时间不同步,老慢几分钟。解决办法:设置NTP服务器,和外网时间同步。下面是最近操作的时间同步方法修改主域控制器上同步Internet时间服务器:主域控制器修改运行gpedit.msc打开本地策略组,路径为:计算机配置-管理模板-系统-Windows时间服务:1.1配置WindowsNTP客户端…

    2022年5月17日
    38

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号