Mavericks 上的 MySQL 服务器启动问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21470193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:56:29  来源:igfitidea点击:

MySQL server start issues on Mavericks

mysqlmacos

提问by user3144542

I am having difficulty using MySQL on my MacBook, I am trying to start my server using sudo mysqld_safeand this results in the following output:

我在我的 MacBook 上使用 MySQL 时遇到困难,我正在尝试启动我的服务器sudo mysqld_safe,这导致以下输出:

140131 00:03:02 mysqld_safe Logging to '/usr/local/var/mysql/david-mbp.err'.
140131 00:03:02 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
140131 00:03:03 mysqld_safe mysqld from pid file /usr/local/var/mysql/david-mbp.pid ended

I had a look at this questionand it has all the same issues and methods I have tried to resolve my issues. His fix was the upgrade to Lion but I am already on the latest version of Mavericks so this is not a viable solution for me.

我看过这个问题,它有我试图解决我的问题的所有相同的问题和方法。他的修复是升级到 Lion,但我已经在使用最新版本的 Mavericks,所以这对我来说不是一个可行的解决方案。

I have googled around and reinstalled numerous times but haven't managed to find why I get this issue.

我已经用谷歌搜索并重新安装了很多次,但没有找到为什么我会遇到这个问题。

How can I fix this issue?

我该如何解决这个问题?

Edit:

编辑:

140131 00:03:02 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
2014-01-31 00:03:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-01-31 00:03:03 13223 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2014-01-31 00:03:03 13223 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/Cellar/mysql/5.6.15/bin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
2014-01-31 00:03:03 13223 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2014-01-31 00:03:03 13223 [Note] InnoDB: The InnoDB memory heap is disabled
2014-01-31 00:03:03 13223 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-01-31 00:03:03 13223 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-01-31 00:03:03 13223 [Note] InnoDB: Using CPU crc32 instructions
2014-01-31 00:03:03 13223 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-01-31 00:03:03 13223 [Note] InnoDB: Completed initialization of buffer pool
2014-01-31 00:03:03 13223 [ERROR] InnoDB: ./ibdata1 can't be opened in read-write mode
2014-01-31 00:03:03 13223 [ERROR] InnoDB: The system tablespace must be writable!
2014-01-31 00:03:03 13223 [ERROR] Plugin 'InnoDB' init function returned error.
2014-01-31 00:03:03 13223 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2014-01-31 00:03:03 13223 [ERROR] Unknown/unsupported storage engine: InnoDB
2014-01-31 00:03:03 13223 [ERROR] Aborting

2014-01-31 00:03:03 13223 [Note] Binlog end
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'partition'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_METRICS'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_CMPMEM'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_CMP'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_LOCKS'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'INNODB_TRX'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'BLACKHOLE'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'ARCHIVE'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'MRG_MYISAM'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'MyISAM'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'MEMORY'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'CSV'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'sha256_password'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'mysql_old_password'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'mysql_native_password'
2014-01-31 00:03:03 13223 [Note] Shutting down plugin 'binlog'
2014-01-31 00:03:03 13223 [Note] /usr/local/Cellar/mysql/5.6.15/bin/mysqld: Shutdown complete

140131 00:03:03 mysqld_safe mysqld from pid file /usr/local/var/mysql/david-mbp.pid ended

ls -l /usr/local/var/mysql output:

ls -l /usr/local/var/mysql 输出:

-rw-rw----   1 dave      admin  50331648 30 Jan 22:35 ib_logfile0
-rw-rw----   1 dave      admin  50331648 30 Jan 22:35 ib_logfile1
-rw-rw----   1 dave      admin  12582912 30 Jan 22:35 ibdata1
drwx------  81 dave      admin      2754 30 Jan 22:35 mysql
drwx------  55 dave      admin      1870 30 Jan 22:35 performance_schema
-rw-r-----   1 _mysql    admin      4784 31 Jan 00:03 david-mbp.err
drwx------   2 dave      admin        68 30 Jan 22:35 test

回答by ATP_JD

File permissions are definitely the cause of the issue. There are far better experts than me, but I recommend the following:

文件权限绝对是问题的原因。有比我更好的专家,但我推荐以下内容:

Ensure your entire data directory is owned by the _mysqluser with permissions drwxr-xr-x.

确保您的整个数据目录归_mysql具有权限的用户所有drwxr-xr-x

In your case, it appears that your MySQL installation directory is your data directory. My data directory is in a subdirectory of the installation directory.

在您的情况下,您的 MySQL 安装目录似乎是您的数据目录。我的数据目录位于安装目录的子目录中。

You can probably get up and running by changing permissions per the command:

您可能可以通过更改每个命令的权限来启动和运行:

sudo chown -R _mysql:admin /usr/local/var/mysql
sudo chmod -R u+rwX,g+rwX,o-rwx /usr/local/var/mysql

This may limit your daveaccount from accessing the mysql installation directory without sudo, so you may wish to tweak these permissions to include g+rwxif your daveuser is a member of the admingroup, which it appears to be. That tweak would be accomplished with:

这可能会限制您的dave帐户在没有 的情况下访问 mysql 安装目录sudo,因此您可能希望调整这些权限以包括g+rwx您的dave用户是否是该admin组的成员,它似乎是。该调整将通过以下方式完成:

sudo chmod -R g+rwx /usr/local/var/mysql

回答by user5349557

i fixed that by simply delete the ".err" file. Somehow the error log owned by "_mysql" and prevent mysqld zu start.

我通过简单地删除“.err”文件来解决这个问题。不知何故,错误日志归“_mysql”并阻止mysqld zu启动。

回答by Caleb

In my case I had a similar problem on Mac OS 10.10 Yosemite. For some reason when I killed the mysql process manually it changed the ownership of the error log file /usr/local/var/mysql/rally.local.errto _mysqlinstead of caleb. Unlike the accepted solution above, the whole rest of my directory is owned by caleb, not _mysql.

就我而言,我在 Mac OS 10.10 Yosemite 上遇到了类似的问题。出于某种原因,当我手动杀了MySQL的过程中它改变了错误日志文件的所有权/usr/local/var/mysql/rally.local.err_mysql代替caleb。与上面接受的解决方案不同,我目录的其余部分都归caleb,而不是_mysql.

I fixed it by running sudo chown caleb /usr/local/var/mysql/rally.local.err

我通过运行修复了它 sudo chown caleb /usr/local/var/mysql/rally.local.err

For the record I guess the proper way to stop and start the mysql server in Yosemite is with /usr/local/var/mysql/mysql.server start|stop|restart.

作为记录,我想在优胜美地停止和启动 mysql 服务器的正确方法是使用/usr/local/var/mysql/mysql.server start|stop|restart.

回答by kenorb

If you don't have any important data, the easiest would be to reinstall MariaDB from scratch (otherwise skip this step), e.g.

如果您没有任何重要数据,最简单的方法是从头重新安装 MariaDB(否则跳过此步骤),例如

mv /usr/local/var/mysql /usr/local/var/mysql.bak
brew reinstall mariadb

Then fix the permissions by:

然后通过以下方式修复权限:

sudo chmod -R u+rwX,g+rwX,o-rwx /usr/local/var/mysql
sudo chown -R $USER:_mysql /usr/local/var/mysql

Restart MariaDB services by:

通过以下方式重新启动 MariaDB 服务:

brew services restart mariadb

Consider configuring your MariaDB credentials by running:

考虑通过运行以下命令来配置您的 MariaDB 凭据:

mysql_secure_installation


Troubleshooting

故障排除

  • In case it still doesn't work, check the logs for any further issues by:

    tail /usr/local/var/mysql/*.err
    
  • For example check if in old config file consist any invalid settings, as they may be not supported anymore.

  • 如果它仍然不起作用,请通过以下方式检查日志是否有任何其他问题:

    tail /usr/local/var/mysql/*.err
    
  • 例如检查旧配置文件中是否包含任何无效设置,因为它们可能不再受支持。