I have a database file (name.sql) that was sent to me that I am supposed to connect to a rails app locally hosted on my mac, that I downloaded (forked?) from github. How do I set up my database.yml file to connect with the sql files.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t connect a Rails application directly to a SQL file. The Rails application gets its data from a database server and you import the contents of the SQL file into a database hosted by the server.
You can download a DMG archive which will install MySQL Community Server on your Mac from http://dev.mysql.com/downloads/mysql/#downloads
That download also includes a handy Preference Pane for starting and stopping the server.
Once you have MySQL up and running then you should set a password for the root user (i.e. the database system administrator) using
—Obviously replace
secretwith the real password you want to use.Then you can set up the
database.ymlfile for the Rails application. For an application named app it would look like this:Note that typically in production you’d create a separate limited privilege database user account for the Rails application to connect to MySQL with, but for development on your local machine the root account is fine.
After this step you can run
rake db:createfrom the root of the Rails application within the Terminal. This command will create theapp_developmentdatabase in MySQL (rake db:create:allcreates the test and production databases too). Finally, you can import your SQL file by entering the following command in the Terminal:You will be prompted for the MySQL root password. Replace
path/to/filewith the full path to the SQL file if it’s not within the Terminal’s current directory. For example, use~/Desktop/name.sqlif it’s on your desktop.