MySql 有问题

MySql 有问题

我昨天安装了 Ubuntu headless server 14.04。当时我唯一安装的是 ssh。我更新了服务器,然后使用他们的自动安装脚本安装了 Plesk。

这是在 hyper-v 上运行的虚拟服务器。我有 12 个核心、16gb 内存和 500gb 硬盘。

我毫无问题地访问了该网站。我还没有有效的 SSL 证书,因为我还没有到那一步。然后我安装了 Plesk 的许可证。我做了一些调查,看看它是如何工作的,然后就去睡觉了。我今天早上开始使用它,但网站却无法打开。当我尝试访问该网站时,我一直被拒绝连接。我四处看了看,它说要尝试修复它

cd /var 
sudo mkdir mysql
sudo chmod 755 mysql
cd mysql
sudo ln -s /tmp/mysql.sock mysql.sock

这使我能够访问该网站。当我尝试在网站上执行任何操作时,我得到以下信息:

错误:PleskDBException:无法连接到数据库:mysql_connect():没有此文件或目录 /var/run/mysqld/mysqld.sock(错误代码:2002)。请检查数据库服务器是否已启动并可访问。(Abstract.php:69)

我检查了 /var/log/mysql/error.log 中的日志,mysql.error 为零字节:

151126 10:59:24 mysqld_safe Number of processes running now: 0
151126 10:59:24 mysqld_safe mysqld restarted
151126 10:59:24 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
151126 10:59:24 [Note] /usr/sbin/mysqld (mysqld 5.5.46-0ubuntu0.14.04.2) starting as process 3082 ...
151126 10:59:24 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
151126 10:59:24 [Note] Plugin 'FEDERATED' is disabled.
151126 10:59:24 InnoDB: The InnoDB memory heap is disabled
151126 10:59:24 InnoDB: Mutexes and rw_locks use GCC atomic builtins
151126 10:59:24 InnoDB: Compressed tables use zlib 1.2.8
151126 10:59:24 InnoDB: Using Linux native AIO
151126 10:59:24 InnoDB: Initializing buffer pool, size = 128.0M
151126 10:59:24 InnoDB: Completed initialization of buffer pool
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
151126 10:59:24  InnoDB: Retrying to lock the first data file
InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
InnoDB: Unable to lock ./ibdata1, error: 11

除了上面提到的内容之外,我没有做任何更改。有人能建议去哪里查看或做什么吗?

附加信息:

[24-Nov-2015 20:23:38 America/Chicago] PHP Warning: chgrp(): Operation not permitted; File: /opt/psa/admin/plib/Plesk/Log.php, Line: 66

[2015-11-24 20:23:38] ERR [1] PHP Warning: chgrp(): Operation not permitted; File: /opt/psa/admin/plib/Plesk/Log.php, Line: 66

[2015-11-24 20:24:19] ERR [1] Module configs is not installed.
[2015-11-24 21:18:21] ERR [panel] [Action Log] Failed login attempt with login 'techguyalabama' from IP 50.2.213.12
[2015-11-24 21:18:28] ERR [panel] [Action Log] Failed login attempt with login 'admin' from IP 50.2.213.12
[2015-11-25 09:30:45] ERR [util_exec] proc_close() failed ['/opt/psa/admin/bin/spammng' '--status'] with exit code [1]
[2015-11-25 09:30:45] ERR [1] '/opt/psa/admin/bin/spammng' '--status' failed with code 1.

stdout:


stderr:
ERROR:spammng:[Errno 2] No such file or directory: '/etc/default/spamassassin'

[2015-11-25 12:49:51] ERR [panel] [Action Log] Failed login attempt with login '<invalid>' from IP 104.238.110.138
[2015-11-26 06:25:03] ERR [panel] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 10:27:18] ERR [panel] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.:
0: /opt/psa/admin/plib/CommonPanel/Application/Abstract.php:69
        CommonPanel_Application_Abstract::initDbAdapter()
1: /opt/psa/admin/plib/Session/Helper.php:150
        Plesk\Session\Helper::initStorage()
2: /opt/psa/admin/plib/auth.php:325
        AutoPrepend->initUserSession()
3: /opt/psa/admin/plib/auth.php:230
        AutoPrepend->run()
4: /opt/psa/admin/plib/auth.php:759
[2015-11-26 10:27:18] ERR [1] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 10:51:37] ERR [panel] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.:
0: /opt/psa/admin/plib/CommonPanel/Application/Abstract.php:69
        CommonPanel_Application_Abstract::initDbAdapter()
1: /opt/psa/admin/plib/Session/Helper.php:150
        Plesk\Session\Helper::initStorage()
2: /opt/psa/admin/plib/auth.php:325
        AutoPrepend->initUserSession()
3: /opt/psa/admin/plib/auth.php:230
        AutoPrepend->run()
4: /opt/psa/admin/plib/auth.php:759
[2015-11-26 10:51:37] ERR [1] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 10:59:31] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 10:59:32] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 10:59:32] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 10:59:32] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:08:57] ERR [panel] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.:
0: /opt/psa/admin/plib/CommonPanel/Application/Abstract.php:69
        CommonPanel_Application_Abstract::initDbAdapter()
1: /opt/psa/admin/plib/api-common/AbstractCu.php:1640
        AbstractCu::initDb()
2: /opt/psa/admin/plib/api-common/AbstractCu.php:1666
        AbstractCu::initCLI()
3: /opt/psa/admin/plib/scripts/setup-health-monitor.php:5
[2015-11-26 11:08:57] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:09:08] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:13:47] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:13:47] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:22:41] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:22:41] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:22:41] ERR [1] Unable to connect to database:  /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:23:32] ERR [panel] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.:
0: /opt/psa/admin/plib/CommonPanel/Application/Abstract.php:69
        CommonPanel_Application_Abstract::initDbAdapter()
1: /opt/psa/admin/plib/Session/Helper.php:150
        Plesk\Session\Helper::initStorage()
2: /opt/psa/admin/plib/auth.php:325
        AutoPrepend->initUserSession()
3: /opt/psa/admin/plib/auth.php:230
        AutoPrepend->run()
4: /opt/psa/admin/plib/auth.php:759
[2015-11-26 11:23:32] ERR [1] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:23:52] ERR [panel] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.:
0: /opt/psa/admin/plib/CommonPanel/Application/Abstract.php:69
        CommonPanel_Application_Abstract::initDbAdapter()
1: /opt/psa/admin/plib/Session/Helper.php:150
        Plesk\Session\Helper::initStorage()
2: /opt/psa/admin/plib/auth.php:325
        AutoPrepend->initUserSession()
3: /opt/psa/admin/plib/auth.php:230
        AutoPrepend->run()
4: /opt/psa/admin/plib/auth.php:759
[2015-11-26 11:23:52] ERR [1] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:23:56] ERR [panel] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.:
0: /opt/psa/admin/plib/CommonPanel/Application/Abstract.php:69
        CommonPanel_Application_Abstract::initDbAdapter()
1: /opt/psa/admin/plib/Session/Helper.php:150
        Plesk\Session\Helper::initStorage()
2: /opt/psa/admin/plib/auth.php:325
        AutoPrepend->initUserSession()
3: /opt/psa/admin/plib/auth.php:230
        AutoPrepend->run()
4: /opt/psa/admin/plib/auth.php:759
[2015-11-26 11:23:56] ERR [1] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.
[2015-11-26 11:24:00] ERR [panel] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.:
0: /opt/psa/admin/plib/CommonPanel/Application/Abstract.php:69
        CommonPanel_Application_Abstract::initDbAdapter()
1: /opt/psa/admin/plib/Session/Helper.php:150
        Plesk\Session\Helper::initStorage()
2: /opt/psa/admin/plib/auth.php:325
        AutoPrepend->initUserSession()
3: /opt/psa/admin/plib/auth.php:230
        AutoPrepend->run()
4: /opt/psa/admin/plib/auth.php:759
[2015-11-26 11:24:00] ERR [1] Unable to connect to database: mysql_connect(): No such file or directory /var/run/mysqld/mysqld.sock (Error code: 2002). Please check that database server is started and accessible.

更多信息:

搜索mysqld.sock和mysql.sock:

> sudo find . -name mysqld.sock
> sudo find . -name mysql.sock
./var/mysql/mysql.sock
> sudo find . -name my.cnf
./etc/mysql/my.cnf

检查了 my.cnf 并且它有以下内容:

#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

该目录是空的:/var/run/mysqld

我不太熟悉 MySql 设置,但我想我会分享这个......

答案1

我今天遇到了这个问题。我只是停止了mysql并重新启动它:

# service mysql stop
mysql stop/waiting
# service mysql start
mysql start/running, process 4042

我不确定如何正确修复此问题。

编辑:

跟踪后,/var/log/mysql/error.log我确定有多个版本的 mysql 尝试运行。我删除了它/etc/init.d/mysql,下次重启时没有收到此错误。

编辑2:

/etc/init.d/mysql首先备份

# This will maintian all file ownership and permissions
# and back this up in your home directory:
cp -ar /etc/init.d/mysql "$HOME" 

相关内容