帮助设置Ruby on Rails和MySQL - 提供奖励

时间:2021-05-13 23:31:17

I am desperately in need of help from any charitable ruby/rails experts out there. I really want to learn RoR, but I can't get anywhere because every time I get to the stage where I need to connect to the database, something is messed up. Here's what I've got going at the moment.

我迫切需要任何慈善的红宝石/铁路专家的帮助。我真的想学习RoR,但我无法到达任何地方,因为每次我到达需要连接到数据库的阶段时,都会搞砸了。这就是我现在要做的事情。

[ Mac OSX 10.6.6 -- Ruby 1.9.2 -- Rails 3.0.5 -- MySQL 5.5.10 ]

[Mac OSX 10.6.6 - Ruby 1.9.2 - Rails 3.0.5 - MySQL 5.5.10]

All of these are the latest versions, freshly installed, and running smoothly. I also have rvm installed. All I want to know is how I can set up a new Rails project using a MySQL database and connect to it properly. I have spent countless hours googling around and getting error after error after error.

所有这些都是最新版本,新安装,运行顺畅。我也安装了rvm。我想知道的是如何使用MySQL数据库建立一个新的Rails项目并正确连接到它。我花了无数个小时谷歌搜索并在错误后出错后收到错误。

Can anyone help me out by outlining step by step how I can just get a working rails project connected to a mysql database? If anyone can help me with this I will not only owe you my life, but I will make amazing web and interface designs for you for free and/or collaborate on your next project as a UI designer. I will in addition give you free photoshop/graphics advising for life.

任何人都可以通过逐步概述如何让一个工作的rails项目连接到mysql数据库来帮助我吗?如果有人能帮助我,我将不仅仅欠你我的生命,而且我将为你免费制作精彩的网页和界面设计,并/或作为UI设计师在你的下一个项目上进行合作。我还将为您提供免费的photoshop / graphics建议。

I want to learn rails so so bad, but I am in over my head right now with this file configuration stuff and wasting massive amounts of time. Please help!

我想学习如此糟糕的rails,但我现在正处于这个文件配置的东西,并浪费了大量的时间。请帮忙!

2 个解决方案

#1


13  

You'll owe me your life!!!! WOW! Seriously, try this:

你欠我一生!!!!哇!说真的,试试这个:

rails new example -d mysql

config.database.yml created

config.database.yml已创建

development:
  adapter: mysql2  
  encoding: utf8
  database: example_development
  pool: 5
  username: root
  password:
  socket: /var/run/mysqld/mysqld.sock

Go into your new project

进入你的新项目

cd example

Then install gems needed (mysql2)

然后安装所需的宝石(mysql2)

bundle install

Then create your database

然后创建数据库

rake db:create

Profit!

利润!

If you can't use /var/run/mysqld/mysqld.sock as a pointer to connect to your mysql, then edit it to look like this https://gist.github.com/878434 and customize the port and username/password

如果您不能使用/var/run/mysqld/mysqld.sock作为连接到您的mysql的指针,那么将其编辑为如下所示https://gist.github.com/878434并自定义端口和用户名/密码

#2


3  

Give a look at this post here :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/

#1


13  

You'll owe me your life!!!! WOW! Seriously, try this:

你欠我一生!!!!哇!说真的,试试这个:

rails new example -d mysql

config.database.yml created

config.database.yml已创建

development:
  adapter: mysql2  
  encoding: utf8
  database: example_development
  pool: 5
  username: root
  password:
  socket: /var/run/mysqld/mysqld.sock

Go into your new project

进入你的新项目

cd example

Then install gems needed (mysql2)

然后安装所需的宝石(mysql2)

bundle install

Then create your database

然后创建数据库

rake db:create

Profit!

利润!

If you can't use /var/run/mysqld/mysqld.sock as a pointer to connect to your mysql, then edit it to look like this https://gist.github.com/878434 and customize the port and username/password

如果您不能使用/var/run/mysqld/mysqld.sock作为连接到您的mysql的指针,那么将其编辑为如下所示https://gist.github.com/878434并自定义端口和用户名/密码

#2


3  

Give a look at this post here :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/