所以……我可能是个白痴,但我被困住了。我刚刚在 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
有人愿意指出我在这里做错了什么吗?
答案1
如果有人偶然发现这个问题,我在这里找到了解决方案: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
答案2
当你运行时:
yum install mysql
命令默认安装 MariaDB 而不是 MySQL。
因此,请尝试以下命令:
yum list installed | grep mariadb
如果mariadb-server
缺少,请尝试以下命令:
yum install mariadb-server
它安装服务器包然后启动服务:
systemctl start mariadb
或者:
service mariadb start
我的问题就这样解决了。
答案3
服务名称如下mariadb
,您可以使用它来启动它:
service mariadb start
使用以下方法停止:
service mariadb stop
并使用以下命令重新启动它:
service mariadb restart
答案4
我在尝试启动 mariadb 服务时遇到了类似的问题
错误 2002 (HY000):无法通过套接字“/var/lib/mysql/mysql.sock”连接到本地 MySQL 服务器
我认为问题出在不匹配的 yum 包上——有些是从特殊的 MariaDB 存储库以及其他来自 centos 官方 repo 的软件包。因此,我不得不删除自定义 yum repo 条目,删除 MariaDB 软件包并重新安装 mariadb-server,然后服务就可以正常启动了。