centos7中MySQL5.7安装成功,但启动失败
来源:13-6 线上环境安装配置实操(mysql)
浣玉
2018-05-15
网上说,centos7的MySQL自启动与centos6的不一样,需要创建mysqld.service文件,下面是这个文件的内容:
[Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=/usr/sbin/mysqld --defaults-file=/etc/my.cnf LimitNOFILE = 5000 # Restart=on-failure # RestartPreventExitStatus=1 # PrivateTmp=false
通过 which mysqld 得到的是/usr/sbin/mysqld,是不是MySQL就安装在这里啊?
我输入:sudo systemctl start mysqld.service
和sudo systemctl status mysqld.service
之后就显示这样了,MySQL server启动失败。老师,这是为什么啊?有同学遇到过这样的情况吗?怎么解决的?万急!万急!感谢!感谢!
[root@iZ2ze9fstvjqgx02nvyip7Z system]# sudo systemctl start mysqld.service [root@iZ2ze9fstvjqgx02nvyip7Z system]# sudo systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Tue 2018-05-15 00:57:37 CST; 18s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 30167 ExecStart=/usr/sbin/mysqld --defaults-file=/etc/my.cnf (code=exited, status=1/FAILURE) Main PID: 30167 (code=exited, status=1/FAILURE) May 15 00:57:35 iZ2ze9fstvjqgx02nvyip7Z systemd[1]: Started MySQL Server. May 15 00:57:35 iZ2ze9fstvjqgx02nvyip7Z systemd[1]: Starting MySQL Server... May 15 00:57:37 iZ2ze9fstvjqgx02nvyip7Z systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILUR May 15 00:57:37 iZ2ze9fstvjqgx02nvyip7Z systemd[1]: Unit mysqld.service entered failed state. May 15 00:57:37 iZ2ze9fstvjqgx02nvyip7Z systemd[1]: mysqld.service failed.
写回答
1回答
-
浣玉
提问者
2018-05-15
下面是原有的mysqld.service 文件,内容如下:
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # systemd service file for MySQL forking server # [Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql Type=forking PIDFile=/var/run/mysqld/mysqld.pid # Disable service start and stop timeout logic of systemd for mysqld service. TimeoutSec=0 # Execute pre and post scripts as root PermissionsStartOnly=true # Needed to create system tables ExecStartPre=/usr/bin/mysqld_pre_systemd # Start main service ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS # Use this to switch malloc implementation EnvironmentFile=-/etc/sysconfig/mysql # Sets open_files_limit LimitNOFILE = 5000 Restart=on-failure RestartPreventExitStatus=1 PrivateTmp=false
012021-04-11
相似问题