================================
©copyright 蕃薯耀 2021-12-31
https://www.cnblogs.com/fanshuyao/
一、MysqL Unit not found 问题
centos7 MysqL --initialize 后启动MysqL(service MysqLd start)报错:Unit not found.
Failed to start MysqL.server.service: Unit not found.
二、MysqL Unit not found 原因
在CentOS 7中已经不在支持MysqL(建议改使用MariaDB),就算已经安装,但CentOS7系统中(/usr/lib/systemd/system)是没有该服务的。
为什么不支持了呢?
MariaDB数据库管理系统是MysqL的一个分支,主要由开源社区在维护,采用GPL授权许可
。开发这个分支的原因之一是:甲骨文公司收购了MysqL后,有将MysqL闭源的潜在风险,
因此社区采用分支的方式来避开这个风险。
三、centos7 MysqL Unit not found 解决方案
1、解决方案一:使用MariaDB代替MysqL数据库
Centos 7默认是已经安装了MariaDB的,如果没有,可自行安装。
#安装mariadb yum install mariadb-server -y #启动服务 systemctl start mariadb.service #设置开机启动 systemctl enable mariadb.service #登录MysqL MysqL -uroot -p
2、解决方案二:手动添加MysqLd.service
(1)进入/usr/lib/systemd/system目录
cd /usr/lib/systemd/system
vi 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 Type=forking # Start main service ExecStart=/usr/bin/MysqLd --defaults-file=/etc/MysqL/my.cnf # Sets open_files_limit LimitNOFILE = 5000
下面的rpm方式安装MysqL自动生成的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 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
(4)重新加载系统服务
systemctl daemon-reload
systemctl enable MysqLd.service systemctl start MysqLd.service
查看MysqL状态
systemctl status MysqLd.service service MysqLd status
3、解决方案二:在线安装 MysqL-server
(1)先安装wget工具,有了可省略
yum -y install wget
wget http://dev.MysqL.com/get/MysqL57-community-release-el7-7.noarch.rpm
没有该镜像,在安装MysqL时(yum -y install MysqL-server)会报错:
没有可用软件包 MysqL-server。
(3)rpm 方式安装MysqL镜像
rpm -ivh MysqL57-community-release-el7-7.noarch.rpms
或者?
yum localinstall -y MysqL57-community-release-el7-7.noarch.rpm
(4)安装MysqL服务
yum -y install MysqL-server
或者?
yum install -y MysqL-community-server
(时间宝贵,分享不易,捐赠回馈,^_^)
================================
©copyright 蕃薯耀 2021-12-31
https://www.cnblogs.com/fanshuyao/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。