在Mac上装Mysql启动不了

我的系统是 OS X 10.8.2,从mysql官网下载了Mac OS X版本的MySQL包,mysql-5.5.28-osx10.6-x86_64
然后复制到

# sudo cp -r ~/mysql-5.5.28-osx10.6-x86_64 /usr/local/mysql-5.5.28

建一个软连接

# sudo ln -s /usr/local/mysql-5.5.28
# ls -l mysql
lrwxr-xr-x  1 root  wheel    12B Nov  3 15:59 mysql -> mysql-5.5.28

我先用mysqld启动,报错

# sudo ./mysqld
121106 17:07:44 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql-5.5.28/data/ is case insensitive
121106 17:07:44 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

121106 17:07:44 [ERROR] Aborting

121106 17:07:44 [Note] ./mysqld: Shutdown complete

然后我用mysqld_safe启动

>sudo ./mysqld_safe 
121106 17:11:46 mysqld_safe Logging to '/usr/local/mysql/data/dev.local.err'.
121106 17:11:46 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
121106 17:11:46 mysqld_safe mysqld from pid file /usr/local/mysql/data/dev.local.pid ended

还是失败。。。无奈了,这个不是编译好的包么?还需要额外干什么吗?

这个是 dev.local.err的文件内容:

121106 21:07:22 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
121106 21:07:22 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/mysql/data/ is case insensitive
121106 21:07:22 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/mysql/bin/mysqld: Table 'mysql.plugin' doesn't exist
121106 21:07:22 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
121106 21:07:22 InnoDB: The InnoDB memory heap is disabled
121106 21:07:22 InnoDB: Mutexes and rw_locks use GCC atomic builtins
121106 21:07:22 InnoDB: Compressed tables use zlib 1.2.3
121106 21:07:22 InnoDB: Initializing buffer pool, size = 128.0M
121106 21:07:22 InnoDB: Completed initialization of buffer pool
121106 21:07:22  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
121106 21:07:22 mysqld_safe mysqld from pid file /usr/local/mysql/data/dev.local.pid ended
阅读 34k
4 个回答

从dev.local.err可以看出来,由于你没有给mysqld_safe指定配置文件,它用了默认路径 “/usr/local/mysql/data” 作为数据文件的路径。该路径很可能没有被创建,所以导致错误。

建议是参照包里给出的my.cnf(my-small.cnf等)修改,然后执行mysqld_safe的时候指定。

121106 17:07:44 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

这个是常规方式启动的报错,不要用 root 用户启动 mysql

建议用homebrew安装MySQL, mac上大部分东西都可以用homebrew管理
http://mxcl.github.com/homebrew/

先装Xcode
brew install mysql
即可

安装完以后还有一段文字说明应该如何初始化+启动数据库, 仔细阅读即可

把安装目录和数据库存放目录的权限用chown赋予mysql账户,让mysqld_safe以mysql用户启动试试看:)

mysqld_safe --user=mysql

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题