How to connect mysql database file to local ruby ​​on rails application

I have a database file (name.sql) that was sent to me that I have to connect to the rails application locally hosted on my mac that I downloaded (forked?) From github. How to configure database.yml file to connect to sql files.

+3
source share
2 answers

Unable to connect Rails application directly to SQL file. The Rails application retrieves its data from the database server and imports the contents of the SQL file into a database hosted on the server.

DMG, MySQL Community Server Mac http://dev.mysql.com/downloads/mysql/#downloads

.

MySQL root (.. ),

mysqladmin -u root password "secret"

&mdash. , secret , .

database.yml Rails. app :

development:
  adapter: mysql
  database: app_development
  username: root
  password: secret
  host: localhost

test:
  adapter: mysql
  database: app_test
  username: root
  password: secret
  host: localhost

production:
  adapter: mysql
  database: app_production
  username: root
  password: secret
  host: localhost

, Rails MySQL, root .

rake db:create Rails . app_development MySQL (rake db:create:all ). , SQL, Terminal :

mysql -u root -p app_development < path/to/file/name.sql

MySQL. path/to/file SQL, . , ~/Desktop/name.sql, .

+5

, : Mac. .

mac , database.yml

0

Source: https://habr.com/ru/post/1754833/


All Articles