Install MySql 2 adapter using gem install:
gem install mysql2
Modify the gemfile for your app by opening it and add the version of the mysql gem you want to use:
gem 'mysql2', '0.3.7'
Create the mysql2 bundle, which links mysql2 gem with its dependencies (to the best of my understanding this is what is going on)
bundle install
If you get the error "Library not loaded: libmysqlclient.18.dylib" it is because the bundle you created earlier doesn't know where to find this dylib (DLL). To fix this, use the Xcode tool install_name_tool:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle
Basically this command says: for this dylib, it is located here, and put that location in the mysql2.bundle
To connect at terminal, use the mysql command, this line logs you in:
/usr/local/mysql/bin/mysql -u root -p
Create a shortcut to the mysql command by adding to your bash path:
echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
Now you can simply type:
mysql -u root -p
database.yml file needs to be configured as such:
development:
adapter: mysql2
database: dbname
host: 127.0.0.1
username: user
password: password
chown -R mysql /usr/local/mysql
chmod -R u+rw /usr/local/mysql
start mysql with:
sudo mysqld --user=root
Set root mysql password with mysqladmin
start mysql monitor with:
mysql -u root -p (p prompts for password)
to shutdown server:
mysqladmin -u root -p shutdown (will prompt for password set above)
To create a new user:
create user 'username'@'localhost' identified by 'password'
Grant the user access:
grant all 'username'@localhost' identified by 'password'
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment