当前位置:网站首页>centos8安装mysql.7 无法开机启动
centos8安装mysql.7 无法开机启动
2022-07-04 06:36:00 【CSDN问答】
问题遇到的现象和发生背景
centos8中安装mysql后,使用命令service mysqld start可以启动数据库,但是通过配置开机启动如下:
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
系统重启无法启动数据库
操作环境、软件版本等信息
操作系统为centos8,数据库为mysql-5.7.38-linux-glibc2.12-x86_64
尝试过的解决方法
关闭selinux之后,mysql可以启动,问题解决。
重新打开selinux;重启系统,数据库依然可以启动。
很懵--到底啥子问题啊,求各位给看下啊
我想要达到的结果
关闭selinux是我从网上找了很多之后实在没有办法下的尝试,我想要能够看到mysql无法启动的具体原因,学习下如何能够快速定位问题。
各位朋友,能帮我看下吗,还有能给推荐点比较好的一些运维知识吗,关于centos和mysql的
附上截图:
运行service mysqld start后,系统正常运行:
reboot系统重启后,mysql数据库无法开机启动,但是通过启动命令可以启动:
[[email protected] bin]# rebootConnection closing...Socket close.Connection closed by foreign host.Disconnected from remote host(10.3.27.1) at 11:42:46.Type `help' to learn how to use Xshell prompt.[D:\~]$ reconnectConnecting to 10.3.27.1:22...Connection established.To escape to local shell, press 'Ctrl+Alt+]'.WARNING! The remote SSH server rejected X11 forwarding request.Activate the web console with: systemctl enable --now cockpit.socketLast login: Mon Jun 27 11:33:13 2022 from 10.3.27.21[[email protected] ~]# ps -ef|grep mysqlroot 1617 1580 0 11:43 pts/0 00:00:00 grep --color=auto mysql[[email protected] ~]# systemctl status mysqld● mysqld.service - LSB: start and stop MySQL Loaded: loaded (/etc/rc.d/init.d/mysqld; generated) Active: active (exited) since Mon 2022-06-27 11:43:28 CST; 22s ago Docs: man:systemd-sysv-generator(8) Process: 1245 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)Jun 27 11:43:28 localhost.localdomain systemd[1]: Starting LSB: start and stop MySQL...Jun 27 11:43:28 localhost.localdomain mysqld[1245]: /etc/rc.d/init.d/mysqld: line 239: /usr/local/mysql/bin/my_print_defaults: Permi>Jun 27 11:43:28 localhost.localdomain mysqld[1245]: Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_sa>Jun 27 11:43:28 localhost.localdomain systemd[1]: Started LSB: start and stop MySQL.
将selinux关闭后,mysql数据库可开机启动:
# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of these three values:# targeted - Targeted processes are protected,# minimum - Modification of targeted policy. Only selected processes are protected.# mls - Multi Level Security protection.SELINUXTYPE=targeted#将SELINUX关闭保存后重启[[email protected] ~]# rebootConnection closing...Socket close.Connection closed by foreign host.Disconnected from remote host(10.3.27.1) at 11:47:35.Type `help' to learn how to use Xshell prompt.[D:\~]$ reconnectConnecting to 10.3.27.1:22...Connection established.To escape to local shell, press 'Ctrl+Alt+]'.WARNING! The remote SSH server rejected X11 forwarding request.Activate the web console with: systemctl enable --now cockpit.socketLast login: Mon Jun 27 11:43:36 2022 from 10.3.27.21[[email protected] ~]# ps -ef|grep mysqlroot 1272 1 0 11:48 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/3306/data --pid-file=/data/mysql/3306/log/mysql.pidmysql 2142 1272 2 11:48 ? 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/3306/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/3306/log/error.log --pid-file=/data/mysql/3306/log/mysql.pid --socket=/data/mysql/3306/tmp/mysql.sock --port=3306root 2313 2277 0 11:48 pts/0 00:00:00 grep --color=auto mysql[[email protected] ~]# systemctl status mysqld● mysqld.service - LSB: start and stop MySQL Loaded: loaded (/etc/rc.d/init.d/mysqld; generated) Active: active (running) since Mon 2022-06-27 11:48:18 CST; 23s ago Docs: man:systemd-sysv-generator(8) Process: 1238 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS) Tasks: 28 (limit: 23364) Memory: 201.6M CGroup: /system.slice/mysqld.service ├─1272 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/3306/data --pid-file=/data/mysql/3306/log/mysql.pid └─2142 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/3306/data --plugin-dir=/usr/local/mys>Jun 27 11:48:15 localhost.localdomain systemd[1]: Starting LSB: start and stop MySQL...Jun 27 11:48:18 localhost.localdomain mysqld[1238]: Starting MySQL... SUCCESS!Jun 27 11:48:18 localhost.localdomain systemd[1]: Started LSB: start and stop MySQL.
将selinux开启后,mysql数据库依然可以开机启动:
[[email protected] ~]# rebootConnection closing...Socket close.Connection closed by foreign host.Disconnected from remote host(10.3.27.1) at 11:51:03.Type `help' to learn how to use Xshell prompt.[D:\~]$ reconnectConnecting to 10.3.27.1:22...Connection established.To escape to local shell, press 'Ctrl+Alt+]'.WARNING! The remote SSH server rejected X11 forwarding request.Activate the web console with: systemctl enable --now cockpit.socketLast login: Mon Jun 27 11:48:29 2022 from 10.3.27.21[[email protected] ~]# ps -ef|grep mysqldroot 1255 1 0 11:54 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/3306/data --pid-file=/data/mysql/3306/log/mysql.pidmysql 2141 1255 0 11:54 ? 00:00:06 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/3306/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/3306/log/error.log --pid-file=/data/mysql/3306/log/mysql.pid --socket=/data/mysql/3306/tmp/mysql.sock --port=3306root 2425 2388 0 13:22 pts/0 00:00:00 grep --color=auto mysqld
附上mysql配置文件:
[client]port = 3306socket = /data/mysql/3306/tmp/mysql.sock [mysqld]server-id = 1port = 3306basedir = /usr/local/mysqldatadir = /data/mysql/3306/datatmpdir = /data/mysql/3306/tmpsocket = /data/mysql/3306/tmp/mysql.sockpid-file = /data/mysql/3306/log/mysql.pidskip_name_resolve = 1character-set-server = utf8mb4transaction_isolation = READ-COMMITTEDcollation-server = utf8mb4_general_ciinit_connect='SET NAMES utf8mb4'lower_case_table_names = 1max_connections = 400max_connect_errors = 1000explicit_defaults_for_timestamp = truemax_allowed_packet = 128Minteractive_timeout = 1800wait_timeout = 1800tmp_table_size = 16Mmax_heap_table_size = 128Mquery_cache_size = 0query_cache_type = 0read_buffer_size = 2Mread_rnd_buffer_size = 8Msort_buffer_size = 8Mbinlog_cache_size = 1M back_log = 130log_error = /data/mysql/3306/log/error.logslow_query_log = 1long_query_time = 1slow_query_log_file = /data/mysql/3306/log/slow.loglog_queries_not_using_indexes = 1log_throttle_queries_not_using_indexes = 5min_examined_row_limit = 100expire_logs_days = 5 log-bin = mysql-binbinlog_format = ROWbinlog_row_image = minimal # Innodb设置innodb_open_files = 500innodb_buffer_pool_size = 64Minnodb_log_buffer_size = 2Minnodb_flush_method = O_DIRECTinnodb_write_io_threads = 4innodb_read_io_threads = 4innodb_lock_wait_timeout = 120innodb_log_file_size = 32Msql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
附上mysql安装过程:
[[email protected] ~]# mkdir /data[[email protected] ~]# cd /data/[[email protected] data]# mkdir software[[email protected] data]# groupadd mysql[[email protected] data]# useradd -g mysql mysql -d /data/mysql[[email protected] data]# passwd mysqlChanging password for user mysql.New password: BAD PASSWORD: The password is shorter than 8 charactersRetype new password: passwd: all authentication tokens updated successfully.[[email protected] data]# mkdir /data/mysql/3306/[[email protected] data]# mkdir /data/mysql/3306/data[[email protected] data]# mkdir /data/mysql/3306/log[[email protected] data]# mkdir /data/mysql/3306/tmp[[email protected] data]# cd /data/software/[[email protected] software]# tar -zxf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz [[email protected] software]# mv mysql-5.7.38-linux-glibc2.12-x86_64 /usr/local/[[email protected] software]# cd /usr/local/[[email protected] local]# ln -s mysql-5.7.38-linux-glibc2.12-x86_64 mysql[[email protected] local]# chown -R mysql:mysql mysql/[[email protected] local]# cd /etc/[[email protected] etc]# chown -R mysql:mysql /data/mysql[[email protected] etc]# cd /usr/local/mysql/bin/[[email protected] bin]# ./mysqld --initialize --user=mysql[[email protected] bin]# vi /data/mysql/3306/log/error.log[[email protected] bin]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld[[email protected] bin]# chmod +x /etc/rc.d/init.d/mysqld[[email protected] bin]# chkconfig --add mysqld[[email protected] bin]# chkconfig --list mysqldNote: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'.mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off[[email protected] bin]# service mysqld startStarting MySQL.. SUCCESS! [[email protected] bin]# ps -ef|grep mysqlroot 5563 1 2 11:41 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql/3306/data --pid-file=/data/mysql/3306/log/mysql.pidmysql 6268 5563 8 11:41 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql/3306/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/3306/log/error.log --pid-file=/data/mysql/3306/log/mysql.pid --socket=/data/mysql/3306/tmp/mysql.sock --port=3306root 6298 5323 0 11:41 pts/0 00:00:00 grep --color=auto mysql[[email protected] bin]#
边栏推荐
- 2022 is probably the best year for the economy in the next 10 years. Did you graduate in 2022? What is the plan after graduation?
- Displaying currency in Indian numbering format
- 内卷怎么破?
- GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
- 《国民经济行业分类GB/T 4754—2017》官网下载地址
- 分布式CAP理论
- 746. Climb stairs with minimum cost
- What is a spotlight effect?
- JSON web token -- comparison between JWT and traditional session login authentication
- Sort list tool class, which can sort strings
猜你喜欢
uniapp 自定义环境变量
leetcode 310. Minimum Height Trees
uniapp 自定義環境變量
what the fuck! If you can't grab it, write it yourself. Use code to realize a Bing Dwen Dwen. It's so beautiful ~!
Variables d'environnement personnalisées uniapp
[March 3, 2019] MAC starts redis
Mysql 45讲学习笔记(七)行锁
How to avoid JVM memory leakage?
GoogleChromePortable 谷歌chrome浏览器便携版官网下载方式
Json Web token - jwt vs. Traditional session login Authentication
随机推荐
Modify TCP timestamp to optimize transmission performance
QT releases multilingual International Translation
Mysql 45讲学习笔记(十四)count(*)
Learning multi-level structural information for small organ segmentation
tcp socket 的 recv 如何接收指定长度消息?
How to choose the middle-aged crisis of the testing post? Stick to it or find another way out? See below
tars源码分析之3
2022.7.3-----leetcode. five hundred and fifty-six
【MySQL】数据库视图的介绍、作用、创建、查看、删除和修改(附练习题)
手动对list进行分页(参数list ,当前页,页面大小)
What is tweeman's law?
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
Learning multi-level structural information for small organ segmentation
How to realize multi account login of video platform members
C实现贪吃蛇小游戏
Realize IIC data / instruction interaction with micro batg135
《国民经济行业分类GB/T 4754—2017》官网下载地址
After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people
QT qtablewidget table column top requirements ideas and codes
Download kicad on Alibaba cloud image station