This repository was archived by the owner on Nov 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Switching from SQLite to MySQL
mjgiarlo edited this page Nov 1, 2012
·
10 revisions
- (OPTIONAL) If you care about the data in your DB, dump it:
rake db:data:dump
- Install MySQL (if you haven't already)
- sudo apt-get install mysql-server (on Ubuntu)
- Edit
config/database.yml
to point at MySQL instead of SQLite
- example database.yml with MySQL configs(https://github.com/psu-stewardship/scholarsphere/blob/master/config/database.yml.sample)
- update the mysql path (/run/mysqld/mysqld.sock on Ubuntu) if you run into database connection issues
- Create a user account for the app in MySQL
- CREATE USER 'user'@'localhost' IDENTIFIED BY 'pass';
- (note this account will only work on your local machine)
- Grant this account privileges to scholarsphere_development, scholarsphere_test, and scholarsphere_production
- GRANT ALL PRIVILEGES ON scholarsphere_development.* TO 'user'@'localhost';
- GRANT ALL PRIVILEGES ON scholarsphere_test.* TO 'user'@'localhost';
- GRANT ALL PRIVILEGES ON scholarsphere_production.* TO 'user'@'localhost';
- Create the dev and test databases:
rake db:create
, followed byRAILS_ENV=test rake db:create
- If you get MySQL errors around here, it could be you need to refresh the MySQL gem within bundler as you may have already built it w/ native extensions on an earlier version of MySQL. If that's the case, try
gem uninstall mysql
followed bybundle install
- Migrate the dev and test databases:
rake db:migrate
, follwed byRAILS_ENV=test rake db:migrate
- (OPTIONAL) Load the data you dumped earlier:
rake db:data:load
- (OPTIONAL) If you run 'rake db:data:load' you must run
git checkout db/data.yml