Can't connect to local MySQL server through socket '/tmp/mysql.sock'

版权声明:本文为博主原创文章,欢迎转载,请注明出处 https://blog.csdn.net/mouday/article/details/84718517

跟着linux安装MySQL教程做的时候,执行到

./bin/mysqladmin -u root password 123456

mysql报错

错误:'Can't connect to local MySQL server through socket '/tmp/mysql.sock'

通过本地ip直接回车可以登录

mysql -uroot -h 127.0.0.1 -p

网上查找资料后发现是MySQL没有找到这个文件,bug吗?

>find / -name mysql.sock
/var/lib/mysql/mysql.sock

原来这文件在这里,MySQL自己创建的文件,自己不知道在哪里,给你跪了,给它做个软连接,告诉他文件地址

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

再执行开头的语句,就成功了

参考
亲测有效,解决Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2) ";

?mysql 的phpMyAdmin不可用,报错Can't connect to local MySQL server through socket '/tmp/mysql.sock'(2)

12-08

我使用的是apache+mysql+php, 想使用phpMyAdmin管理mysql,无奈不能成功,详情如下:rnrn安装步骤: rn1.安装mysqlrn $rpm -ivh mysql-3.23.56-1.73.i386.rpmrn $rpm -ivh mysqlclient9-3.23.22-8.i386.rpmrn $rpm -ivh mysql-devel-3.23.56-1.73.i386.rpmrn $rpm -ivh mysql-server-3.23.56-1.73.i386.rpmrn2.解压缩APACHE: rn shell>tar -xzvf apache_1.3.28.tar.gzrn shell> cd apache_1.3.28rn shell>patch -p0 < ../no_zombies.patch rnrn3.apache第一次编译rn 并不要安装,因为php的编译需要apache至少已经编译过一次 rn cd apache_1.3.28 rn ./configure --prefix=/var/www rn 解压缩PHP:rn shell> tar -xzvf php-4.1.2.tar.gz rn shell> cd php-4.1.2 rn 配置编译安装PHP:rn shell>./configure --with-mysql --with-apache=../apache_1.3.28 --enable-track-vars --with-xml --with-apx rn 配置PHP支持MYSQL,作为APACHE功能模块运行rn rn shell>makern shell>make installrn4.配置APACHE:rn shell>cd /root/apache_1.3.28rn shell> ./configure --prefix=/var/www/ --activate-module=src/modules/php4/libphp4.a rn 将PHP作为APACHE的一个模块静态编译rn shell> make rn shell> make install rnrn这样安装好了后,mysql命令行可用,apache可用,php可用,但是我将phpMyAdmin拷入主目录下,在别的机器的IE上键入: http://192.168.0.1/phpMyAdmin/后,报错:rn报错Can't connect to local MySQL server through socket '/tmp/mysql.sock'(2) rnrn注:mysql,phpMyAdmin配置应该无误.rn我自己怀疑是不是编译的时候,没把php支持mysql编译进去.因为:我后来编了一个测试页:rn rn结果显示项中:rnconfigure command : './configure' '--with-apache=../apache_1.3.28' '--enable-track- vars' '--with-xml' '--with-apx'rn好象与我编译时用的命令:>./configure --with-mysql --with-apache=../apache_1.3.28 --enable-track-vars --with-xml --with-apx 有出入.rn但由于我的mysql是rpm安装的,如果我用:>./configure --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.28 --enable-track-vars --with-xml --with-apx rn编译又通不过,说是头文件没有.rn请问高手,此问题该怎么解决,那些头文件又在哪里呢?rn 论坛

没有更多推荐了,返回首页