9

ERROR 2002 (HY000): 无法通过套接字 '/var/run/mysqld/mysqld.sock' 连接到本地 MySQL 服务器 (2)

我尝试了在互联网上找到的所有内容,但无法解决 Ubuntu 11.04 上的问题。

我尝试了这些事情:

  • 使用手动启动 mysqldsudo /usr/sbin/mysqld start
  • 使用 mysqld 启动service mysqld start
  • 检查它正在运行ps ax | grep mysqld并得到结果3419 pts/0 S+ 0:00 grep --color=auto mysqld
  • 手动创建文件/var/run/mysqld/mysqld.sock
  • 赋予mysql用户权限
  • 试图删除并重新安装,但它仍然无法正常工作
  • 尝试tasksel配置 LAMP,其他一切正常,但 mysql 产生相同的错误。

使用它运行时mysqld -P 3305会产生错误

110630  0:24:24 [Warning] Can't create test file /var/lib/mysql/nazar-studio.lower-test
110630  0:24:24 [Warning] Can't create test file /var/lib/mysql/nazar-studio.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
110630  0:24:24 [ERROR] Aborting

110630  0:24:24 [Note] mysqld: Shutdown complete

这是mysql错误日志

10630  0:07:22 [Note] Plugin 'FEDERATED' is disabled.
110630  0:07:22  InnoDB: Initializing buffer pool, size = 8.0M
110630  0:07:22  InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
110630  0:07:22  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
110630  0:07:22  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
110630  0:07:22  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
110630  0:07:23  InnoDB: Started; log sequence number 0 0
110630  0:07:23  InnoDB: Starting shutdown...
110630  0:07:28  InnoDB: Shutdown completed; log sequence number 0 44233
110630  0:07:28 [Note] Plugin 'FEDERATED' is disabled.
110630  0:07:28  InnoDB: Initializing buffer pool, size = 8.0M
110630  0:07:28  InnoDB: Completed initialization of buffer pool
110630  0:07:28  InnoDB: Started; log sequence number 0 44233
ERROR: 1064  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ALTER TABLE user ADD column Show_view_priv enum('N','Y') CHARACTER SET utf8 NOT ' at line 1
110630  0:07:28 [ERROR] Aborting

110630  0:07:28  InnoDB: Starting shutdown...
110630  0:07:34  InnoDB: Shutdown completed; log sequence number 0 44233
110630  0:07:34 [Note] /usr/sbin/mysqld: Shutdown complete

110630  0:07:34 [Note] Plugin 'FEDERATED' is disabled.
110630  0:07:34  InnoDB: Initializing buffer pool, size = 8.0M
110630  0:07:34  InnoDB: Completed initialization of buffer pool
110630  0:07:34  InnoDB: Started; log sequence number 0 44233
110630  0:07:34  InnoDB: Starting shutdown...
110630  0:07:39  InnoDB: Shutdown completed; log sequence number 0 44233
110630  0:07:39 [Note] Plugin 'FEDERATED' is disabled.
110630  0:07:39  InnoDB: Initializing buffer pool, size = 8.0M
110630  0:07:39  InnoDB: Completed initialization of buffer pool
110630  0:07:39  InnoDB: Started; log sequence number 0 44233
ERROR: 1050  Table 'plugin' already exists
110630  0:07:39 [ERROR] Aborting

110630  0:07:39  InnoDB: Starting shutdown...
110630  0:07:44  InnoDB: Shutdown completed; log sequence number 0 44233
110630  0:07:44 [Note] /usr/sbin/mysqld: Shutdown complete

110630  0:18:30 [Note] Plugin 'FEDERATED' is disabled.
110630  0:18:30  InnoDB: Initializing buffer pool, size = 8.0M
110630  0:18:30  InnoDB: Completed initialization of buffer pool
110630  0:18:30  InnoDB: Started; log sequence number 0 44233
mysqld: Too many arguments (first extra is 'start').
Use --verbose --help to get a list of available options
110630  0:18:30 [ERROR] Aborting

110630  0:18:30  InnoDB: Starting shutdown...
110630  0:18:35  InnoDB: Shutdown completed; log sequence number 0 44233
110630  0:18:35 [Note] mysqld: Shutdown complete

如何解决此错误?

4

6 回答 6

16

我做了实验,最后用这些命令解决了

sudo chown mysql:root /var/lib/mysql/ -R
sudo chmod g+rw /var/lib/mysql/ -R
sudo /usr/sbin/mysqld --skip-grant &

它开始运行...... Hurraaahhhhhhhhhh !!!!!!!!!!!!

于 2011-06-29T20:57:54.023 回答
4

您的日志实际上告诉您问题:

mysqld:参数太多(第一个额外是“开​​始”)。

只需启动不带“开始”一词的守护程序。代替:

sudo /usr/sbin/mysqld 开始

它应该只是:

须藤/usr/sbin/mysqld

于 2014-04-15T20:51:25.337 回答
1

如果您安装了多个 mysql 服务器,请确保运行正确的 MYSQL 或更改路径设置。例如:

/opt/lampp/bin/mysql -u root -p 

我安装了 XAMPP,该解决方案对我有用。

于 2012-07-23T06:44:11.537 回答
1

看起来它无法在 /var/lib/mysql/ 中创建文件。如果您查看errode 13,则通常表示权限错误。

1) 确保 mySQL 可以写入目录 /var/lib/mysql 和/或 mySQL 拥有该目录。做一个:

cd /var/lib ; ls -la | grep mysql

为了确定。

2) 如果您尝试以 mySQL 用户启动,请改用 root 启动它(您可能是,但值得检查)。

3) 如果您正在运行 SElinux 之类的东西,请确保启用它以进行 mySQL 访问。我怀疑情况是否如此,但值得检查。

4) 小提示:不要创建 sock 文件——一旦启动并正常运行,mysql 就会创建一个。如果它仍在运行目录中,请将其删除。

于 2011-06-29T19:51:27.557 回答
0

尝试使用终止套接字(这可能取决于您的操作系统)

rm /var/lib/mysql/mysql.sock rm:删除套接字`/var/lib/mysql/mysql.sock'?y 重启服务

服务 mysqld 启动

于 2015-03-23T20:50:19.720 回答
0

你有没有尝试过?

sudo touch /etc/apparmor.d/local/usr.sbin.mysqld

更多背景信息:https ://askubuntu.com/a/127029

于 2016-05-02T06:30:28.010 回答