mariadb-server安装后没有mysqld或mysql.server


33

所以...可能我是个白痴,但我被困住了。我只是在Digial Ocean上设置了CentOS 7,但似乎无法运行MariaDB / MySQL服务器。

一些输出

[root@hostname ~]# yum list installed |grep maria
mariadb.x86_64                        1:5.5.37-1.el7_0                @updates  
mariadb-libs.x86_64                   1:5.5.37-1.el7_0                @updates  
mariadb-server.x86_64                 1:5.5.37-1.el7_0                @updates  

这样就安装好了,我们至少可以看到客户端吗?

[root@hostname ~]# which mysql
/bin/mysql

让我们尝试启动服务器,只是为了好玩

[root@hostname ~]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
Failed to issue method call: Unit mysqld.service failed to load: No such file or directory.
[root@hostname ~]# mysqld
-bash: mysqld: command not found
[root@hostname ~]# mysql.server start
-bash: mysql.server: command not found
[root@hostname ~]# 

这就是我迷路的地方。查看实际安装的内容,没有服务器/守护程序

[root@hostname ~]# ls -la /bin/my*
-rwxr-xr-x 1 root root 3419136 Jun 24 10:27 /bin/myisamchk
-rwxr-xr-x 1 root root 3290760 Jun 24 10:27 /bin/myisam_ftdump
-rwxr-xr-x 1 root root 3277032 Jun 24 10:27 /bin/myisamlog
-rwxr-xr-x 1 root root 3320200 Jun 24 10:27 /bin/myisampack
-rwxr-xr-x 1 root root 2914904 Jun 24 10:27 /bin/my_print_defaults
-rwxr-xr-x 1 root root 3533016 Jun 24 10:27 /bin/mysql
-rwxr-xr-x 1 root root  111587 Jun 24 10:24 /bin/mysqlaccess
-rwxr-xr-x 1 root root 3089712 Jun 24 10:27 /bin/mysqladmin
-rwxr-xr-x 1 root root 3253112 Jun 24 10:27 /bin/mysqlbinlog
lrwxrwxrwx 1 root root      26 Sep  8 03:06 /bin/mysqlbug -> /etc/alternatives/mysqlbug
-rwxr-xr-x 1 root root 3090832 Jun 24 10:27 /bin/mysqlcheck
-rwxr-xr-x 1 root root    4247 Jun 24 10:24 /bin/mysql_convert_table_format
-rwxr-xr-x 1 root root   24558 Jun 24 10:24 /bin/mysqld_multi
-rwxr-xr-x 1 root root   27313 Jun 24 10:24 /bin/mysqld_safe
-rwxr-xr-x 1 root root 3173968 Jun 24 10:27 /bin/mysqldump
-rwxr-xr-x 1 root root    7913 Jun 24 10:24 /bin/mysqldumpslow
-rwxr-xr-x 1 root root    3315 Jun 24 10:24 /bin/mysql_find_rows
-rwxr-xr-x 1 root root    1261 Jun 24 10:24 /bin/mysql_fix_extensions
-rwxr-xr-x 1 root root   34826 Jun 24 10:24 /bin/mysqlhotcopy
-rwxr-xr-x 1 root root 3082072 Jun 24 10:27 /bin/mysqlimport
-rwxr-xr-x 1 root root   16204 Jun 24 10:24 /bin/mysql_install_db
-rwxr-xr-x 1 root root 2923136 Jun 24 10:27 /bin/mysql_plugin
-rwxr-xr-x 1 root root   11578 Jun 24 10:24 /bin/mysql_secure_installation
-rwxr-xr-x 1 root root   17473 Jun 24 10:24 /bin/mysql_setpermission
-rwxr-xr-x 1 root root 3084760 Jun 24 10:27 /bin/mysqlshow
-rwxr-xr-x 1 root root 3104240 Jun 24 10:27 /bin/mysqlslap
-rwxr-xr-x 1 root root 3442464 Jun 24 10:27 /bin/mysqltest
-rwxr-xr-x 1 root root 2918416 Jun 24 10:27 /bin/mysql_tzinfo_to_sql
-rwxr-xr-x 1 root root 2995400 Jun 24 10:27 /bin/mysql_upgrade
-rwxr-xr-x 1 root root 2913960 Jun 24 10:27 /bin/mysql_waitpid
-rwxr-xr-x 1 root root    3888 Jun 24 10:24 /bin/mysql_zap

有人指出我在做什么错吗?

Answers:


40

如果有人偶然发现,我在这里找到了解决方案:https : //ask.fedoraproject.org/en/question/43459/how-to-start-mysql-mysql-isnt-starting/

在下面重新发布


要在Fedora 20上启动MariaDB,请执行以下命令:

systemctl start mariadb.service

要在Fedora 20上自动启动MariaDB,请执行以下命令:

systemctl enable mariadb.service

启动MariaDB(仅执行一次)之后,执行以下命令:

/usr/bin/mysql_secure_installation

4
尝试中sudo systemctl start mariadb,我得到了Failed to start mariadb.service: Unit mariadb.service failed to load: No such file or directory.
donquixote 2015年

2
sudo systemctl enable mysqldsudo systemctl start mysqld似乎之前没有做过花招。
donquixote 2015年

感谢@donquixote我在使用systemd之前(需要在启动之前启用)从未遇到过这种行为。看起来mysqld.service可以在启动后成功禁用,而不停止服务。我想显式启动和停止mysql服务,而不希望它在启动时自动运行。
lsh

13

运行时:

yum install mysql

该命令默认会安装MariaDB而不是MySQL。

因此,请尝试以下命令:

yum list installed | grep mariadb

如果mariadb-server缺少,请尝试以下命令:

yum install mariadb-server

它安装服务器软件包,然后启动服务:

systemctl start mariadb

要么:

service mariadb start

我的问题就这样解决了。


截至2016年末,这似乎是正确的答案。在CentOS上安装mysql时,它将安装maria db,但可能未安装服务器(这很奇怪)。
Craig Jacobs

彻底而简单的解释,甚至奏效了!我正在使用新的Amazon Linux。谢谢!
musicin3d

3

服务名称是,mariadb因此您可以使用以下命令启动它:

service mariadb start

使用以下命令停止它:

service mariadb stop

并使用以下命令重新启动它:

service mariadb restart

2
CentOS 7正在使用systemd,因此您应该使用适当的systemctl命令代替旧service命令。
斯文

2

查看是否mysqld/usr/libexec/目录下。至少在CentOS 6.5中,通常的MySQL将服务器本身安装在此处。

另请参阅输出,systemctl list-units以查看您的MariaDB服务器的名称。


mysqld确实存在于/usr/libexec/目录中。但是,我在systemctl list-units命令的输出中看不到任何有关MariaDB(或MySQL)的信息
danneth 2014年

1

我在尝试启动mariadb服务时遇到了类似的问题

错误2002(HY000):无法通过套接字'/var/lib/mysql/mysql.sock'连接到本地MySQL服务器

我认为问题出在不匹配的yum软件包中-有些是从特殊的mariadb存储库安装的,而另一些是从centos官方存储库安装的。因此,我必须删除自定义的yum repo条目,删除MariaDB软件包并重新安装mariadb-server,然后服务才能启动而不会出现问题。


输出状态@updates为存储库,因此这里似乎不是这种情况。这可能对其他人仍然有用,因此感谢您的分享:-)
jornane

0

@OP请选择最佳答案;@主持人请锁定问题;

遇到同样的问题,尝试了所提到的其他步骤,但均无济于事;我的问题是在退出su并运行后以root / sudo su身份登录,$ systemctl status mariadb我收到了

mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

然后我跑$ sudo systemctl enable mariadbrecieving

Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

然后使用以下命令启动mariadb- $ sudo systemctl start mariadb没有错误/消息,因此应该不错,但对检查没有害处$ systemctl status mariadb

mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2018-10-17 10:07:00 CDT; 5min ago
  Process: 18093 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 18000 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 18092 (mysqld_safe)
    Tasks: 20
   CGroup: /system.slice/mariadb.service
           ├─18092 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─18261 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock

Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: MySQL manual for more instructions.
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: Please report any problems at http://mariadb.org/jira
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: The latest information about MariaDB is available at http://mariadb.org/.
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: You can find additional information about the MySQL part at:
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: http://dev.mysql.com
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: Consider joining MariaDB's strong and vibrant community:
Oct 17 10:06:58 centos-7.shared mariadb-prepare-db-dir[18000]: https://mariadb.org/get-involved/
Oct 17 10:06:58 centos-7.shared mysqld_safe[18092]: 181017 10:06:58 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Oct 17 10:06:58 centos-7.shared mysqld_safe[18092]: 181017 10:06:58 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Oct 17 10:07:00 centos-7.shared systemd[1]: Started MariaDB database server.
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.