使用最新版本的 Ruby on Rails 设置 MYSQL

发布于 2024-10-24 05:40:19 字数 1459 浏览 1 评论 0原文

我是一名 Ruby on Rails 新手,我一直在尝试遵循 Lynda.com 的 Ruby on Rails 3 基本培训。然而,这是在 mysql 是默认数据库时进行的,不知何故,从那时起默认数据库已更改为 sqlite3。

我完全不知道如何处理与 ruby​​、迁移或数据库相关的任何事情,并且按照本教程进行操作需要我能够从默认的 sqlite 更改为 mysql。有没有人可以帮助我做到这一点?我想到目前为止我已经把一切都搞砸了,所以这就是我所做的记录:

1。安装了mysql。它在我的 Mac 上运行并工作。这是我进入 mysql 界面时显示的内容:

欢迎使用 MySQL 监视器。命令以 ; 结尾或\g。 你的 MySQL 连接 ID 是 8 服务器版本:5.5.9 MySQL 社区服务器 (GPL)

版权所有 (c) 2000、2010,Oracle 和/或其附属公司。版权所有。

Oracle 是 Oracle Corporation 和/或其公司的注册商标 附属机构。其他名称可能是其各自的商标 业主。

输入“帮助”;或“\h”寻求帮助。键入“\c”以清除当前输入语句。

2.将databases.yml改为mysql结构,例如:

开发: 适配器:mysql2 编码:utf8 数据库:simple_cms_development 用户名:simple_cms 密码: 密码 套接字:/tmp/mysql.sock

3。进入 gemfile 并添加 gem 'mysql2',尽管我也将 sqlite3 保留在那里。 4. 运行“bundle install”以确保 mysql2 gem 已安装。由于之前的错误,它一直将捆绑包中的所有内容放入名为 mysql2 的文件夹中,因此我将路径更改为“gems” 5. 运行“gem list”并且 mysql2 在列表中

然后我运行 db:migrate 并收到此错误,我查找并尝试了在该站点上找到的每个解决方案,但没有一个一个起作用了。

耙子中止! dlopen(/Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle,9):库未加载:libmysqlclient.16.dylib 引用自:/Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle 原因:找不到图像 - /Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle /Users/Jeff/Sites/simple_cms/Rakefile:4

我完全被难住了,遗憾的是,如果我无法克服这一点,我将无法学习更多的 Rails。有人可以帮忙吗?太感谢了 : )

I am a total ruby on rails noob, and I have been trying to follow Lynda.com's ruby on rails 3 essential training. However, this was made when mysql was the default database, and somehow since then the default has been changed to sqlite3.

I have absolutely no idea how to handle anything related to ruby, migrations, or databases, and following along with the tutorial requires me being able to change over from the default of sqlite to mysql. Is there anyone that can help me do this? I think I have so far managed to completely screw everything up, so here's what I did for the record:

1. Installed mysql. Its running and working on my mac. This is whats displayed when I go into the mysql interface:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.5.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

2. Changed databases.yml over to the mysql structure, for example:

development:
adapter: mysql2
encoding: utf8
database: simple_cms_development
username: simple_cms
password: password
socket: /tmp/mysql.sock

3. Went into the gemfile and added gem 'mysql2', although I kept the sqlite3 one in there as well.
4. Ran 'bundle install' to make sure that the mysql2 gem was installed. It kept putting everything from the bundle into a folder called mysql2 due to an earlier mistake, so I changed the path to 'gems'
5. Ran 'gem list' and mysql2 was in the list

Then I ran db:migrate and got this error, which I looked up and tried every single solution I found on this site, and not a single one worked.

rake aborted!
dlopen(/Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib
Referenced from: /Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
/Users/Jeff/Sites/simple_cms/Rakefile:4

I am completely and totally stumped, and sadly will not be able to learn any more rails if I can't get past this. Can anyone help? Thank you so much : )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹿! 2024-10-31 05:40:19

这是一个旧的:)

就这样做:

sudo install_name_tool -change libmysqlclient.16.dylib \
  /usr/local/mysql/lib/libmysqlclient.16.dylib \
  /Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

来源:http://freddyandersen.wordpress.com/2010/10/03/mysql-5-5-snow-leopard-and-rails/

install_name_tool 文档:http://developer.apple.com/库/mac/#documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html

This is an old one :)

Just do:

sudo install_name_tool -change libmysqlclient.16.dylib \
  /usr/local/mysql/lib/libmysqlclient.16.dylib \
  /Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

Source: http://freddyandersen.wordpress.com/2010/10/03/mysql-5-5-snow-leopard-and-rails/

install_name_tool documentation: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文