为什么我无法在 ec2 linux 实例上启动 mysql 服务

为什么我无法在 ec2 linux 实例上启动 mysql 服务

当我在我的 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 实例。谢谢!

答案1

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

无法创建/写入文件‘/var/tmp/ibdSw66G...权限被拒绝’

另外尝试 chown mysql.mysql /var/lib/mysql/ -R; chmod 1777 /var/tmp 一下,您是否阅读过/尝试过这个:

无法打开 mysql.plugin 表。请运行 mysql_upgrade 来创建 它。

答案2

尝试这个:

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

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

telnet 127.0.0.1 3306

可能只是 /etc/ 中的 my.cnf 文件中的错误配置(取决于 Linux 发行版)。

相关内容