Tuesday, January 18, 2011

Migrating to MySQL

Diaspora has chosen to move from NoSQL to SQL (too much relational data). As of this writing, they are only known to support MySQL, since that's what they're running on joindiaspora.com, AFAIK. Here are my hoops, on Ubuntu...
https://github.com/diaspora/diaspora/wiki/Migrating-from-MongoDB-to-MySQL

  1. Update your source
    • git fetch upstream

    • git checkout master

    • git pull upstream master

  2. Install mysql packages
    • apt-get install mysql-server mysql-client libmysqlclient16-dev

  3. Make sure you're utf8 all the way, Diaspora is
    • sudo vi /etc/mysql/my.cnf
      1. Update the server section [mysqld]
        • collation_server=utf8_bin

          character_set_server=utf8

      2. Update the client section [mysql]
        • default-character-set = utf8

  4. Restart MySQL
    • service mysql restart

  5. Create your database.yml
    • cp config/database.yml.example config/database.yml

  6. Edit your new yaml file to suit your environment
    • Note As of this writing, only the MySQL user root can migrate from mongo to MySQL

  7. Create the necessary databases and tables
    • rake db:drop:all
      • Make sure test, development, and production all have valid credentials (for root mysql user)

      • You can safely ignore messages like:
        Couldn't drop diaspora_production : <Mysql2::Error: Unknown database 'diaspora_production'>

    • rake db:create

    • rake db:migrate

    • rake migrations:migrate_to_mysql





Voila, you should now have everything you need to help the community continue to test this massive change...

No comments:

Post a Comment