firstruby

Master ruby with us

Posts Tagged ‘mysql’

Mysql::Error: query: not connected while rake db:migrate

Posted by firstruby on August 25, 2011

With Ruby 1.9.2 and Rails 3.0.10,
If you are facing following problem while doing “rake db:migrate”,

Mysql::Error: query: not connected: SHOW TABLES

then you may need to download ‘libmySQL’ from http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll and paste that in C:\Ruby192\bin folder.

Posted in Useful Links | Tagged: , , , , | Leave a Comment »

Reset MySQL password on Windows

Posted by firstruby on October 26, 2008

1) Log in as Administrator.

2) Stop the MySQL service. Go to Start menu > Control Panel > Administrative Tools > Services > Stop MySQL service.

3) Create “mysql-init.txt” file with following 2 lines,

UPDATE mysql.user SET Password=PASSWORD(‘mypassword’) WHERE User=’root’;
FLUSH PRIVILEGES;

4) Open command prompt, and give following command to reset MySQL password,

“C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld-nt” –defaults-file=”C:\Program Files\MySQL\MySQL Server 5.0\my.ini” –init-file=C:\\mysql-init.txt

The appropriate –defaults-file setting can be found using the Services Manager: From the Start menu, select Control Panel, then Administrative Tools, then Services. Find the MySQL service in the list, right-click it, and choose the Properties option. The Path to executable field contains the –defaults-file setting.

5) After the server has started successfully, delete C:\mysql-init.txt

Posted in Useful Links | Tagged: , | 1 Comment »

Import and Export Database to/from MySQL

Posted by firstruby on October 23, 2008

Small stuff about how to import and export data to/from MySQL with the help of mysql and mysqldump commands,

IMPORT database to MySQL,

D:\>mysql -u username -p password database_name < file.sql

database_name should be there in database. Put your username, password and database_name with yours MySQL information. After this command, data from file.sql will be imported to your database.

EXPORT database from MySQL,

D:\>mysqldump -u username -p password database_name > file.sql

Please replace username, password and database_name with yours MySQL information.

After this command, data will be exported to file.sql

Posted in Useful Links | Tagged: | Leave a Comment »

Access Remote MySQL database in RubyonRails application

Posted by firstruby on October 23, 2008

To give the remote access to database, on server, we have to give the following command,

mysql> CREATE DATABASE foo_development;
mysql> GRANT ALL ON
foo_development.* TO root@'192.168.1.25' IDENTIFIED BY 'PASSWORD';

where 192.168.1.25 – IP Address of the client machine,

Now modify  ../config/database.yml file in our RoR application as follows,

development:
adapter: mysql
database: foo_development
username: root
password: PASSWORD
host: 192.168.1.1

where 192.168.1.1 – IP Address of server

Posted in firstruby, Useful Links | Tagged: , | 1 Comment »