Reputation: 607
I've long been a user of sqlite3 (with rails) and I never got a chance to try mysql, until now. I need to configure to use it along with Datamapper. Following the tutorial I need to install the dm-mysql-adapter using this command:
sudo apt-get install libmysqlclient-dev
My .rb
file contains the following code:
require 'data_mapper'
DataMapper.setup(:default, "mysql://user:password@hostname/database")
class Post
include DataMapper::Resource
property :id , Serial
property :title , String
property :body , Text
property :created_at , DateTime
end
Which doesn't run and gives me the following error:
in `require': no such file to load -- dm-mysql-adapter (LoadError)
I believe, I need to set up a username and password to get mysql up and running and then establish a connection with Datamapper. Can someone please guide me.
Thanks a lot!
Upvotes: 2
Views: 2826
Reputation: 3536
What you're probably getting wrong is that you haven't installed your mysql server. Do this:
sudo apt-get install mysql-server
During the installation, you'll be prompted for a password. Now your mysql server should be running. Use this command to check if it is running:
sudo netstat -tap | grep mysql
Now you need to login as a user and create a database which you'll use in your datamapper
mysql -u root -p
and when logged in, write
$ create database my_db;
Now in put these values in the datamapper setup call for eg.
DataMapper.setup(:default, "mysql://root:password@localhost/my_db")
Hope that helps ;)
Upvotes: 6