当前位置: > 数据库 > MariaDB >

centos通过yum安装mariadb(mysql)无法启动服务或者找不到mysql.sock

时间:2016-05-14 02:05来源:linux.it.net.cn 作者:IT
今天在某云主机(centos7)安装(yum install方式)mariadb(即开源mysql)后,无法启动mariadb,其实是安装不完整,当然启动不了,更不用说输入"mysql -u root"提示Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)了 。没什么技术含量的解决方法开始了。

  安装mariadb,先搜索一发:

 
1
<SPAN style="FONT-SIZE: 14px">$ sudo yum search mariadb</SPAN>

出现:

 
$ sudo yum search mariadb
Loaded plugins: langpacks
============================= N/S matched: mariadb =============================
mariadb-bench.x86_64 : MariaDB benchmark scripts and data
mariadb-devel.i686 : Files for development of MariaDB/MySQL applications
mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb-embedded.i686 : MariaDB as an embeddable library
mariadb-embedded.x86_64 : MariaDB as an embeddable library
mariadb-embedded-devel.i686 : Development files for MariaDB as an embeddable : library
mariadb-embedded-devel.x86_64 : Development files for MariaDB as an embeddable  : library
mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients
mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients
mariadb-server.x86_64 : The MariaDB server and related files
mariadb.x86_64 : A community developed branch of MySQL
mariadb-test.x86_64 : The test suite distributed with MariaD
 

嗯,把 mariadb mariadb-bench mariadb-server mariadb-embdedeb mariadb-libs mariadb-server都安装:

$  yum install mariadb-embedded mariadb-libs mariadb-bench mariadb mariadb-sever

启动mariadb,再试试"mysql -u root“发现可以了,好吧,作为一个Archlinuxer表示centos(或者说rpm系列?)的mariadb打包分得真细。

  哦,那些个什么service xx start的命令在很多新版本的linux发行版上已经不适用了正确的打开方式是systemctl  [option] [xx],mariadb(mysql)使用:

 $ systemctl start mariadb

centos何时用systemctl的我不知道,至少centos7用systemctl。开机自启动:

$ systemctl enable mariadb

(闲话)网上一堆老的不能再老的网页内容实在让菜鸟如我又不爱用什么centos(以及土豪reahat-贴吧常冒出新手问古董redhat的问题……所谓教材的毒害啊)十分无奈,解决不了啊。有说yum安装rpm的mysql(mariadb)默认mysql.sock文件不在默认位置即/var/lib/mysql/,而在/temp/xxx下,要修改my.conf(现在mariadb的配置文件是my.cnf,少了一个o)里面的sock配置,或者软链接到默认位置;有的说权限问题如何如何;有的说卸载安装如何如何………其实只是安装不完整的啦。我的印象里,debian用apt装软件,拖家带口的,aptitude install mysql的话,全家桶应该必然的。这个小问题让我一阵好找,原来只是没安装全,除了服务器我还真没怎么用过centos或者fedora,呵呵哒。




(责任编辑:IT)
------分隔线----------------------------