Ubuntu,mysql服务器连接

大家好,请忽略我的noobness,

我的问题从在Ubuntu 12.04连接到MySQL开始

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

并经过debugging和谷歌search后,我发现在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的configuration

 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_dbmysql_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服务,有人build议重新安装MySQL,但仍然无法使其正确。 请帮帮我。

谢谢

我会尝试以下内容:

 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。

我会首先尝试错误行的build议,如“请运行mysql_upgrade创build它”。

然后,我将通过运行df -h来检查您的mysql分区上的磁盘空间,并确保有足够的可用空间。 同时运行htopfree -m来检查tmpfs的内存利用率,并确保有足够的空间。 无法写入其中一行的tmp空间意味着空间问题。

innoDB的使用也有问题,所以这可能需要进一步调查。

还要确保MySQL正在运行。 但是,我认为你不能启动MySQL,而是根据你的评论来判断。