macos Lion 上的 MySQL 5.5 不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9075850/
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-10-21 08:49:18  来源:igfitidea点击:

MySQL 5.5 on Lion not working

mysqlmacososx-lion

提问by bricker

I've installed MySQL 5.5 via the disk image on Mac OS X 10.7. I've also added /usr/local/mysql/binto my path in .bash_profile.

我已经通过 Mac OS X 10.7 上的磁盘映像安装了 MySQL 5.5。我还添加/usr/local/mysql/bin到我的路径中.bash_profile

which mysqlreturns /usr/local/mysql/bin/mysql

which mysql回报 /usr/local/mysql/bin/mysql

However, I can't seem to get the server running, no matter whatever I try.

但是,无论我尝试什么,我似乎都无法让服务器运行。

mysql -u rootreturns:

mysql -u root返回:

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

sudo /usr/local/mysql/bin/mysqld_safestarts and then immediately stops the daemon:

sudo /usr/local/mysql/bin/mysqld_safe启动然后立即停止守护进程:

120130 23:18:57 mysqld_safe Logging to '/usr/local/mysql/data/Bryans-Macbook-Pro.local.err'.
120130 23:18:57 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
120130 23:18:59 mysqld_safe mysqld from pid file /usr/local/mysql/data/Bryans-Macbook-Pro.local.pid ended

I feel that I have tried every possible solution that can be found, and I am out of ideas now. I've even tried installing an older version of MySQL (5.1) and got the same results and efforts invain.

我觉得我已经尝试了所有可以找到的可能的解决方案,现在我已经没有想法了。我什至尝试安装旧版本的 MySQL (5.1) 并获得相同的结果和努力是徒劳的。

FURTHER INFORMATION

更多信息

Running mysqldresults in:

运行mysqld结果:

$ mysqld
120209  0:02:23 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.5.20-osx10.6-x86_64/data/ is case insensitive
120209  0:02:23 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
120209  0:02:23 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
120209  0:02:23 InnoDB: The InnoDB memory heap is disabled
120209  0:02:23 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120209  0:02:23 InnoDB: Compressed tables use zlib 1.2.3
120209  0:02:23 InnoDB: Initializing buffer pool, size = 128.0M
120209  0:02:23 InnoDB: Completed initialization of buffer pool
120209  0:02:23 InnoDB: highest supported file format is Barracuda.
120209  0:02:23 InnoDB: 1.1.8 started; log sequence number 1595675
120209  0:02:23 [ERROR] mysqld: unknown option '--skip-locking'
120209  0:02:23 [ERROR] Aborting

120209  0:02:23  InnoDB: Starting shutdown...
120209  0:02:24  InnoDB: Shutdown completed; log sequence number 1595675
120209  0:02:24 [Note] mysqld: Shutdown complete

UPDATE

更新

Well, I removed mysql completely from my system, re-installed an older version (5.1), and it is actually starting up now. However, I still can't run rails server. I get the following error:

好吧,我从我的系统中完全删除了mysql,重新安装了一个旧版本(5.1),现在它实际上已经启动了。但是,我仍然无法运行rails server。我收到以下错误:

/Users/bricker/.rvm/gems/ruby-1.8.7-p352/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlopen(/Users/bricker/.rvm/gems/ruby-1.8.7-p352/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: /opt/local/lib/mysql5/mysql/libmysqlclient_r.16.dylib (LoadError)

So, I've run this command:

所以,我运行了这个命令:

sudo install_name_tool -change libmysqlclient_r.16.dylib /opt/local/lib/mysql5/mysql/libmysqlclient_r.16.dylib ~/.rvm/gems/ruby-1.8.7-p352/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle

But still receive the error when attempting to start the 'rails server'.

但是在尝试启动“rails 服务器”时仍然收到错误消息。

UPDATE 2

更新 2

Okay, final update: After everything, reinstalling mysql numerous times, seeing all these errors - it turns out that perhaps the original problem was a conflict between gems mysql2-0.2.7and mysql2-0.3.11. To ultimately fix the problem:

好的,最后更新:毕竟,无数次重新安装mysql,看到所有这些错误 - 结果可能是原始问题是 gemsmysql2-0.2.7mysql2-0.3.11. 最终解决问题:

  1. Removed all mysql-related files from my system (see bash script below)

  2. Installed MySQL 5.1.61 (64-bit) from the Disk Image provided on the MySQL website

  3. Ran the following lines:

  1. 从我的系统中删除了所有与 mysql 相关的文件(请参阅下面的 bash 脚本)

  2. 从 MySQL 网站上提供的磁盘映像安装 MySQL 5.1.61(64 位)

  3. 运行以下几行:

sudo install_name_tool -change libmysqlclient_r.16.dylib /opt/local/lib/mysql5/mysql/libmysqlclient_r.16.dylib ~/.rvm/gems/ruby-1.8.7-p352/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle

sudo install_name_tool -change libmysqlclient_r.16.dylib /opt/local/lib/mysql5/mysql/libmysqlclient_r.16.dylib ~/.rvm/gems/ruby-1.8.7-p352/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle

sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib ~/.rvm/gems/ruby-1.8.7-p352/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle

sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib ~/.rvm/gems/ruby-1.8.7-p352/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle

  1. ran gem uninstall mysql2, and selected the version 0.3.11- the only version left on this RVM section is mysql2-0.2.7.
  1. 运行gem uninstall mysql2,并选择了版本0.3.11- 此 RVM 部分中唯一剩下的版本是mysql2-0.2.7.

Now everything seems to be working! Thanks again for all the help.

现在一切似乎都在工作!再次感谢所有的帮助。

Bash script to remove mysql-related files from Mac OS X (10.6 & 10.7).

用于从 Mac OS X(10.6 和 10.7)中删除 mysql 相关文件的 Bash 脚本。

#!/bin/bash
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf ~/Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*
echo "Done."

Copy into remove-mysql.sh, make it executable (chmod +x remove-mysql.sh), and run it.

复制到 中remove-mysql.sh,使其可执行 ( chmod +x remove-mysql.sh),然后运行它。

采纳答案by Timur

  1. Run mysql_upgrade
  2. Remove skip-lockingoption from my.cnf: MySQL - what does skip-locking in my.cnf do?
  1. mysql_upgrade
  2. 从以下skip-locking选项中删除选项my.cnfMySQL - my.cnf 中的跳过锁定有什么作用?

If you cannot find skip-lockingin your my.cnf, that means that MySQL loads it from path different to your expectations. Double-check that.

如果skip-locking在您的 中找不到my.cnf,则意味着 MySQL 从与您期望的路径不同的路径加载它。仔细检查一下。

P.S. It seems that you upgraded your MySQL from some old version, aren't you?

PS 看来您是从某个旧版本升级了 MySQL,不是吗?

回答by RolandoMySQLDBA

In one of the lines in the error log, this caught my attention

在错误日志的其中一行中,这引起了我的注意

120209  0:02:23 [ERROR] mysqld: unknown option '--skip-locking'

I think --skip-lockingis a pretty old option.

我认为--skip-locking是一个相当古老的选择

You might want to replace that in my.cnf with skip-external-lockinginstead

你可能会想,以取代在my.cnf跳跃外锁,而不是

Since you removed --skip-lockinggo find datadir in my.cnf and make sure you are pointing that variables where the mysql data is located.

由于您删除--skip-locking了在 my.cnf 中查找 datadir 并确保您指向 mysql 数据所在的变量。

回答by technocrat

Sounds (to me) like you have a permissions issue.

听起来(对我来说)你有权限问题。

Check the perms on the following directories:

检查以下目录上的权限:

/usr/local/mysql/bin
/usr/local/mysql/data
/usr/local/mysql/include
/usr/local/mysql/lib
/usr/local/mysql/scripts
/usr/local/mysql/share
...
/usr/local/mysql/*

/usr/local/mysql/bin
/usr/local/mysql/data
/usr/local/mysql/include
/usr/local/mysql/lib
/usr/local/mysql/scripts
/usr/local/mysql/share
.. .
/usr/local/mysql/*

They should all be read/write/excute for the mysql user and mysql group

对于 mysql 用户和 mysql 组,它们都应该是读/写/执行的

Read more on install layout: http://dev.mysql.com/doc/refman/5.5/en/macosx-installation-pkg.html#mysql-installation-layout-macosx

阅读有关安装布局的更多信息:http: //dev.mysql.com/doc/refman/5.5/en/macosx-installation-pkg.html#mysql-installation-layout-macosx

mysql_safe script: I think it might do a user switch to the "user" mysql. Read more on that: http://dev.mysql.com/doc/refman/5.5/en/mysqld-safe.html

mysql_safe 脚本:我认为它可能会将用户切换到“用户”mysql。阅读更多相关信息:http: //dev.mysql.com/doc/refman/5.5/en/mysqld-safe.html

回答by FreudianSlip

Check to ensure your data directory is readable/writable by mysql.

检查以确保您的数据目录可由 mysql 读取/写入。

Try to run mysqld_safe --skip-locking &

尝试运行 mysqld_safe --skip-locking &

That should start the server in the background. Then login with "mysql" .. it shouldn't ask for any credentials.

那应该在后台启动服务器。然后使用“mysql”登录..它不应该要求任何凭据。

Check to see if you have any users defined within the user table on the mysql database.

检查是否在 mysql 数据库的用户表中定义了任何用户。

You mayhave to manually add a user (as the grants system is bypassed above) using :

可能需要使用以下命令手动添加用户(因为上面绕过了授权系统):

use mysql
insert into users <standard insert record stuff here>

When done, come out of the mysql client and do a killall -s1 mysqld.. you may need to do a killall -s 15 mysqldto get the backgrounded job to finish cleanly. Please dont do a -9on the poor old process.

完成后,退出 mysql 客户端并执行killall -s1 mysqld.. 您可能需要执行 akillall -s 15 mysqld才能使后台作业干净利落地完成。请不要-9对糟糕的旧流程进行操作。

Jobs/kill %% etc can be used as well.

也可以使用 Jobs/kill %% 等。

回答by Jonas m

Try this first

先试试这个

sudo /Library/StartupItems/MySQLCOM/MySQLCOM start

Seems like you need to install it right and let it create the sock file needed

似乎您需要正确安装它并让它创建所需的 sock 文件

回答by Anh Nguyen

Just run mysql_install_dbfrom your /usr/localdirectory. For more info, see this blog post.

只需mysql_install_db从您的/usr/local目录运行。有关更多信息,请参阅此博客文章