Linux
Ubuntu、mysql伺服器連接
大家好,請忽略我的菜鳥,
我的問題從在 ubuntu 12.04 上連接到 mysql 開始
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
在調試和Google搜尋後,我在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,但我仍然無法使其正確。請幫我。
謝謝
我會嘗試以下方法:
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。
我首先會嘗試錯誤行的建議,如“請執行 mysql_upgrade 來創建它。”。
df -h
然後,我將通過執行並確保有足夠的可用空間來檢查您的 mysql 分區上的磁碟空間。還執行htop
或free -m
檢查您的記憶體使用率tmpfs
並確保您有足夠的空間。tmp
無法在其中一行中寫入空間意味著空間問題。innoDB 的使用似乎也存在問題,因此這可能需要進一步調查。
還要確保當時 MySQL 正在執行。但是,從您的評論來看,我假設您無法啟動 MySQL。