CentOS7 下启动、关闭、重启、查看MySQL服务

1.启动命令

[root@iZuf625ohgv150cwlh1yn4Z bin]# service mysqlid start
Redirecting to /bin/systemctl start mysqlid.service
或者使用:
systemctl start mysqld

2.关闭命令

[root@iZuf625ohgv150cwlh1yn4Z bin]#  service mysqld stop
Redirecting to /bin/systemctl stop  mysqld.service

systemctl start mysqld

3.重启命令

[root@iZuf625ohgv150cwlh1yn4Z bin]#   service mysqld restart
Redirecting to /bin/systemctl restart  mysqld.service

systemctl start mysqld

4.查看服务状态

[root@iZuf625ohgv150cwlh1yn4Z sbin]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service

#查看mysql状态
systemctl status mysqld

● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2021-04-10 14:25:15 CST; 10min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 12683 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 12666 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 12686 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─12686 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Apr 10 14:25:14 iZuf625ohgv150cwlh1yn4Z systemd[1]: Starting MySQL Server...
Apr 10 14:25:15 iZuf625ohgv150cwlh1yn4Z systemd[1]: Started MySQL Server.

5.查看MySql系统配置

[root@iZuf625ohgv150cwlh1yn4Z sbin]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
port=8306
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

#key_buffer_size指定用于索引的缓冲区大小,增加它可得到更好的索引处理性能。对于内存在4GB左右的服务器该参数可设置为256M或384M。注意:该参数值设置的过大反而会是服务器整体效率降低!
key_buffer_size = 128M 
posted @ 2021-04-10 14:37  雪漠阳光  阅读(2170)  评论(0编辑  收藏  举报