Insertion failed in remote database


I am trying to connect to remote MySQL server through rails. It is able
to create table through db:migrate. but it gives following error
can not connect to local mysql server through socket

while inserting data. we are trying to insert data through rhtml form .



def r_save
@sub = = params[:sub][:name]


plz. help me to solve the query…
we have made necessary correction in database.yml


Are you using a different connection in config/database.yml? If you’re
trying to connect to a local database, it means that the host is set to
localhost. Make sure that all of your connection settings are correct in
your database config. If you think they are all correct, post the
contents of that file here.