且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

由于MySQL错误而无法运行迁移

更新时间:2023-02-15 17:03:01

为解决此问题,我最终使用了mysql2 gem而不是mysql gem.这个过程一点也不简单,因此我想发布我所采取的确切步骤,以防以后有人需要帮助.

To fix the problem I ended up using the mysql2 gem instead of the mysql gem. This process was not straight forward at all, so I wanted to post the exact steps I took in case someone needs help later.

首先,从mysql网站下载与您的OS X版本相对应的OS X DMG文件.您将需要安装mysql,然后安装启动项,最后安装首选项面板(所有这三个都在DMG文件中).

First, download the OS X DMG file that corresponds to your version of OS X from the mysql website. You will need to install mysql, then the startup item, and finally the preferences panel (All 3 of these were in the DMG file).

接下来,您需要将mysql添加到您的path变量中.我相信您可以编辑/etc/paths或将新文件添加到/etc/paths.rd/,但最终还是修改了终端的配置文件.我在〜/.zshrc中添加了以下行(这仅适用于zsh,如果您使用bash,则该文件类似于〜/.bashrc):

Next, you need to add mysql to your path variable. I believe you can edit /etc/paths or add a new file to /etc/paths.rd/, but I ended up modifying my terminal's configuration file. I added the following line to ~/.zshrc (This is only for zsh, if you use bash the file is something like ~/.bashrc):

export PATH=[path:variables]:/usr/local/mysql/bin
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"

[path:variables]只是那里所有其他路径变量的占位符.第二行是使mysql2 gem运行所需的内容.第二行允许mysql查找所需的库文件.

[path:variables] is just a place holder for all of the other path variables that were there. The second line is something that was required to get the mysql2 gem working. The second line allows mysql to find a required library file.

下一步,替换或添加

gem 'mysql' 

gem 'mysql2', '< 0.3'

<要求为0.3,否则会引发一些奇怪的错误. (对不起,我没有保存堆栈跟踪).最后一步是将数据库适配器更改为mysql2.我希望这可以帮助某人省下很多头痛:)

The < 0.3 was required, otherwise some weird errors were thrown. (Sorry, I didn't save the stack trace). The final step is to change your database adapters to mysql2. I hope this can help someone save a great deal of headache :)