Linux

為什麼我不能在 ec2 linux 實例上啟動 mysql 服務

  • May 8, 2017

在我的 ec2 ami linux 實例上通過 ssh 啟動 mysql 時出現此錯誤:

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

在執行“mysql”命令之前,我嘗試啟動 mysql 服務:

sudo service mysqld start

但失敗了。

我檢查了指定目錄中的 mysql.sock ,但它失去了。到底是怎麼回事?

編輯 我還更改了對這些目錄的權限:

/var/lib/mysql/ => 755
all sub-directories in /var/lib/mysql => 700
all files in /var/lib/mysql => 660

編輯 我剛剛在我的 redhat ami ec2 實例上解除安裝並重新安裝了 mysql。而且我仍然無法啟動mysql服務。

編輯

這是我的mysql日誌:

   170506 04:31:30 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
   2017-05-06 04:31:30 6516 [Note] Plugin 'FEDERATED' is disabled.
   ^G/usr/libexec/mysql56/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
   2017-05-06 04:31:30 6516 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
   2017-05-06 04:31:30 6516 [Note] InnoDB: Using atomics to ref count buffer pool pages
   2017-05-06 04:31:30 6516 [Note] InnoDB: The InnoDB memory heap is disabled
   2017-05-06 04:31:30 6516 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
   2017-05-06 04:31:30 6516 [Note] InnoDB: Memory barrier is not used
   2017-05-06 04:31:30 6516 [Note] InnoDB: Compressed tables use zlib 1.2.8
   2017-05-06 04:31:30 6516 [Note] InnoDB: Using Linux native AIO
   2017-05-06 04:31:30 6516 [Note] InnoDB: Using CPU crc32 instructions
   ^G/usr/libexec/mysql56/mysqld: Can't create/write to file '/var/tmp/ibdSw66G' (Errcode: 13 - Permission denied)
   2017-05-06 04:31:30 7faa567fd840  InnoDB: Error: unable to create temporary file; errno: 13
   2017-05-06 04:31:30 6516 [ERROR] Plugin 'InnoDB' init function returned error.
   2017-05-06 04:31:30 6516 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
   2017-05-06 04:31:30 6516 [ERROR] Unknown/unsupported storage engine: InnoDB
   2017-05-06 04:31:30 6516 [ERROR] Aborting
2017-05-06 04:31:30 6516 [Note] Binlog end
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'partition'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'ARCHIVE'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_METRICS'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_CMPMEM'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_CMP'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_LOCKS'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'INNODB_TRX'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'BLACKHOLE'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'CSV'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'MEMORY'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'MyISAM'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'MRG_MYISAM'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'sha256_password'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'mysql_old_password'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'mysql_native_password'
2017-05-06 04:31:30 6516 [Note] Shutting down plugin 'binlog'
2017-05-06 04:31:30 6516 [Note] /usr/libexec/mysql56/mysqld: Shutdown complete

編輯

我現在也用這個命令完全解除安裝並重新安裝了 mysql 幾次:

sudo yum -y remove mysql-server
sudo yum -y install mysql-server

編輯

好吧,算了……哈哈。我剛剛啟動了一個新的 amz ec2 linux 實例。謝謝!

‘./mysql/plugin.frm’ (errno: 13 - 權限被拒絕)

無法創建/寫入文件’/var/tmp/ibdSw66G …權限被拒絕’

也試試 chown mysql.mysql /var/lib/mysql/ -R; chmod 1777 /var/tmp ,你有沒有讀過/試過這個:

無法打開 mysql.plugin 表。請執行 mysql_upgrade 來創建 它。

試試這個:

mysql -h 127.0.0.1 -P 3306 -u root -p <database>

另外(查看它是否正在執行):

telnet 127.0.0.1 3306

可能這只是 /etc/ 中 my.cnf 文件中的錯誤配置(取決於 Linux 發行版)。

引用自:https://serverfault.com/questions/848734