🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# centos8安装mysql5.7 ## 查看系统安装过mysql数据库 rpm -qa | grep mysql ## 如果安装了 卸载掉之前的 rpm -e --nodeps 后面跟系统自带的MySQL名 2.在usr目录下面创建mysql目录 \#cd /usr \#mkdir mysql 如果没有权限,切换用户到root,然后再执行#mkdir mysql命令 3.进入到mysql目录下面 \#cd mysql 4.下载mysql安装包 yum install wget \#wget<https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm> 5.安装用来配置安装MySQL的包 \#rpm -Uvh mysql57-community-release-el6-9.noarch.rpm 报错: ``` <pre class="calibre13">``` All matches were filtered out by modular filtering <span class="token2">for</span> argument<span class="token1">:</span> mysql<span class="token">-</span>community<span class="token">-</span>server Error<span class="token1">:</span> Unable to find a match<span class="token1">:</span> mysql<span class="token">-</span>community<span class="token">-</span>server ``` ``` yum module disable mysql yum -y install mysql-community-server ``` <pre class="calibre13">``` Error<span class="token1">:</span> Problem<span class="token1">:</span> cannot install the best candidate <span class="token2">for</span> the job <span class="token">-</span> nothing provides libsasl2<span class="token1">.</span>so<span class="token1">.</span><span class="token5">2</span><span class="token1">(</span><span class="token1">)</span><span class="token1">(</span><span class="token5">64</span>bit<span class="token1">)</span> needed by mysql<span class="token">-</span>community<span class="token">-</span>server<span class="token">-</span><span class="token5">5.7</span><span class="token5">.36</span><span class="token">-</span><span class="token5">1.</span>el6<span class="token1">.</span><span class="token3">x86_64</span> <span class="token1">(</span><span class="token2">try</span> to add <span class="token4">'--skip-broken'</span> to skip uninstallable packages or <span class="token4">'--nobest'</span> to use not only best candidate packages<span class="token1">)</span> ``` ``` 对应方案则是 找到 /etc/yum.repos.d/mysql-community.repo 打开后,找到 \[mysql57-community\] 这一块配置(将加粗的两个位置更新一下) baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ gpgcheck=0 yum module disable mysql yum -y install mysql-community-server systemctl start mysqld 报错: ``` <pre class="calibre13">``` System has not been booted <span class="token2">with</span> systemd <span class="token2">as</span> init <span class="token3">system</span> <span class="token1">(</span><span class="token5">PID</span> <span class="token5">1</span><span class="token1">)</span><span class="token1">.</span> Can't operate<span class="token1">.</span> Failed to connect to bus<span class="token1">:</span> Host is down ``` ``` 如果你按照网上的一些教程,使用systemd命令,如sudo systemctl start。 令你惊讶的是,该命令的结果是这样的错误。 System has not been booted with systemd as init system (PID 1). Can't operate. 原因:您的Linux系统没有使用systemd。 原因是你想用systemd命令来管理Linux上的服务,但你的系统并没有使用systemd,(很可能)使用的是经典的SysV init(sysvinit)系统。 但这怎么可能呢?你使用的是Ubuntu,教程也是针对同一版本的Ubuntu。为什么你不能用呢? 如果你在Windows里面用WSL使用Ubuntu,那么你的系统就会有SysV而不是systemd,当你运行systemctl命令时,你的系统就会抱怨(针对Linux系统的systemd init系统)。 如何知道你使用的是哪个init系统?你可以使用这个命令来知道与PID 1(系统上运行的第一个进程)相关联的进程名称。 ps -p 1 -o comm= 它应该在输出中显示systemd或sysv(或类似的东西)。 如何解决'System has not been booted with systemd'错误? 答案很简单,就是不要使用systemctl命令,而是使用等同的sysvinit命令。相反,可以使用对应的sysvinit命令。 这并不复杂,而且这两个命令的语法有些相似。 # \*\*失败告终 # \*\*