连接到本地MySQL服务器

连接到本地MySQL服务器

本文介绍了Ubuntu:无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器(2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Ubuntu 14.04.在运行 Owncloud 的地方安装了 LAMP 的服务器.我尝试安装 paperwork 但没有成功但这不是问题.

I have a Ubuntu 14.04. server with LAMP installed where an Owncloud is running. I tried to install paperwork which didn't work out but thats not the problem.

重新启动服务器后,我尝试再次访问自己的云,但遇到内部服务器错误.见下图.自己的云错误

After restarting my server I tried to access my owncloud again but I am facing an internal server error. See following picture.Owncloud error

我查看了日志/var/log/apache2/error.log 并且有以下短语:

I looked in the log /var/log/apache2/error.log and theres following phrase:

Lost connection to MySQL server during query' in ...

我尝试重启mysql服务但是出现这个错误:

I tried to restart the mysql service but this error appears:

stop: Unknown instance:
start: Job failed to start

然后我尝试使用 mysql -u root -p 登录到 mysql 并且出现以下错误:

Then I tried to login to mysql with mysql -u root -p and follorwing error appears:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

我用 find/-type s 在机器上寻找套接字,套接字在那里: /run/mysqld/ .我创建了一个符号链接并将其粘贴到 /var/run/mysqld/mysqld.sock

I've looked for the sockets on the machine with find / -type s and the socket was there: /run/mysqld/ .I created a symbolic link and pasted it to /var/run/mysqld/mysqld.sock

不幸的是没有任何效果.再次重新启动后,我再也找不到套接字 find/-type s 的输出是:

Unfortnutely nothing worked. After restarting again I can't find the socket anymore the output of find / -type s is:

/dev/log
/run/php5-fpm.sock
/run/udev/control
find: `/proc/977/task/977/fd/5': No such file or directory
find: `/proc/977/task/977/fdinfo/5': No such file or directory
find: `/proc/977/fd/5': No such file or directory
find: `/proc/977/fdinfo/5': No such file or directory

更新

我已经重新安装了服务器,所以问题解决了 :D

I've reinstalled the server so problem is over :D

推荐答案

如果你安装了lampp服务器,先运行mysql

If you install lampp server, run mysql first

sudo /opt/lampp/lampp startmysql

然后在/var/run 中创建mysqld"目录

Then make "mysqld" directory in /var/run

cd /var/run
sudo mkdir mysqld

将你的mysql从lampp链接到/var/run/mysqld

Link your mysql from lampp to /var/run/mysqld

sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock

运行 mysql -u root -p .希望能帮到你

run mysql -u root -p . hope may help you

这篇关于Ubuntu:无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器(2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:36