大家好,请忽略我的菜鸟身份,
我的问题从连接到 ubuntu 12.04 上的 mysql 开始
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
经过调试和谷歌搜索后,我在 error.log 中发现以下内容,
130714 11:23:45 [Note] Plugin 'FEDERATED' is disabled.
^G/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
130714 11:23:45 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
130714 11:23:45 InnoDB: The InnoDB memory heap is disabled
130714 11:23:45 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130714 11:23:45 InnoDB: Compressed tables use zlib 1.2.3.4
^G/usr/sbin/mysqld: Can't create/write to file '/tmp/ibcN8p9L' (Errcode: 13)
130714 11:23:45 InnoDB: Error: unable to create temporary file; errno: 13
130714 11:23:45 [ERROR] Plugin 'InnoDB' init function returned error.
130714 11:23:45 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130714 11:23:45 [ERROR] Unknown/unsupported storage engine: InnoDB
130714 11:23:45 [ERROR] Aborting
这是我的一些配置/etc/mysql/my.cnf
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
这是我通过运行获得的磁盘空间信息df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda 20G 2.0G 17G 11% /
udev 246M 4.0K 246M 1% /dev
tmpfs 100M 200K 99M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 248M 0 248M 0% /run/shm
这是我的内存利用率详细信息
total used free shared buffers cached
Mem: 495 93 401 0 16 49
-/+ buffers/cache: 28 467
Swap: 0 0 0
当我运行mysql_install_db
或mysql_upgrade
(正如错误详细信息中所说)它给了我
Installing MySQL system tables...
Installation of system tables failed! Examine the logs in
/var/lib/mysql for more information.
You can try to start the mysqld daemon with:
shell> /usr/sbin/mysqld --skip-grant &
and use the command line tool /usr/bin/mysql
to connect to the mysql database and look at the grant tables:
shell> /usr/bin/mysql -u root mysql
mysql> show tables
Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.
Please consult the MySQL manual section
'Problems running mysql_install_db', and the manual section that
describes problems on your OS. Another information source are the
MySQL email archives available at http://lists.mysql.com/.
Please check all of the above before mailing us! And remember, if
you do mail us, you MUST use the /usr/scripts/mysqlbug script!
我在 Google 上搜索了很多,有人说要重启然后启动 mysql 服务,有人建议重新安装 mysql,但我仍然无法纠正。请帮帮我。
谢谢
答案1
我会尝试以下操作:
sudo mv /var/lib/mysql /var/lib/mysql_bak
sudo mysql_install_db
sudo /etc/init.d/mysql start
sudo netstat -anp | grep 3306
本质上,您正在备份 MySQL 数据目录,然后重新初始化它并启动 MySQL。netstat 命令将检查是否有任何进程在端口 3306 上监听。
如果启动 MySQL 时遇到问题,请再次检查 error.log。
答案2
我将首先尝试错误行所建议的操作,例如“请运行 mysql_upgrade 来创建它。”。
然后,我将通过运行来检查 mysql 分区上的磁盘空间df -h
,并确保有足够的可用空间。同时运行htop
或free -m
检查内存利用率,并确保有足够的空间。其中一行中tmpfs
出现无法写入空间的情况意味着存在空间问题。tmp
innoDB 的使用似乎也存在问题,因此可能需要进一步调查。
同时还要确保 MySQL 正在运行。不过,根据您的评论,我假设您无法启动 MySQL。