简体   繁体   English

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

[英]Setting up MYSQL with the latest version of Ruby on 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. 我是Rails noob上的红宝石,我一直在尝试遵循Lynda.com的rails 3上的红宝石基本培训。 However, this was made when mysql was the default database, and somehow since then the default has been changed to sqlite3. 但是,这是在mysql是默认数据库的情况下进行的,此后默认将其更改为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. 我完全不知道如何处理与ruby,迁移或数据库有关的任何内容,并且跟随本教程的学习要求我能够从默认的sqlite切换到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. 1.安装了mysql。 Its running and working on my mac. 它在我的Mac上运行和运行。 This is whats displayed when I go into the mysql interface: 这是我进入mysql界面时显示的内容:

Welcome to the MySQL monitor. 欢迎使用MySQL监视器。 Commands end with ; 命令以;结尾; or \\g. 或\\ g。 Your MySQL connection id is 8 Server version: 5.5.9 MySQL Community Server (GPL) 您的MySQL连接ID是8服务器版本:5.5.9 MySQL社区服务器(GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. 版权所有(c)2000、2010,Oracle和/或其分支机构。 All rights reserved. 版权所有。

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Oracle是Oracle Corporation和/或其分支机构的注册商标。 Other names may be trademarks of their respective owners. 其他名称可能是其各自所有者的商标。

Type 'help;' 输入“帮助;” or '\\h' for help. 或'\\ h'寻求帮助。 Type '\\c' to clear the current input statement. 键入“ \\ c”以清除当前输入语句。

2. Changed databases.yml over to the mysql structure, for example: 2.将databases.yml更改为mysql结构,例如:

development: adapter: mysql2 encoding: utf8 database: simple_cms_development username: simple_cms password: password socket: /tmp/mysql.sock 开发:适配器:mysql2编码:utf8数据库:simple_cms_development用户名:simple_cms密码:密码套接字:/tmp/mysql.sock

3. Went into the gemfile and added gem 'mysql2' , although I kept the sqlite3 one in there as well. 3.进入gemfile并添加gem'mysql2' ,尽管我也将sqlite3保留在其中。 4. Ran 'bundle install' to make sure that the mysql2 gem was installed. 4.运行“捆绑安装”以确保已安装mysql2 gem。 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 由于先前的错误,它会将软件包中的所有内容都放到名为mysql2的文件夹中,因此我将路径更改为“ gems” 5。运行“ gem list”,并且mysql2在列表中

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. 然后我运行db:migrate并得到了这个错误,我查询并尝试了在此站点上找到的每个解决方案,但没有一个起作用。

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 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

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 : ) 非常感谢 : )

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/ 资料来源: 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 install_name_tool文档: http : //developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM