Monday, May 4, 2009

4) Exporting SQL database from Bioslax and importing to another server's SQL database

To export SQL database from Bioslax and import to another server's SQL database (e.g. proline.bic.nus.edu.sg)

a) Type the following command in Bioslax Konsole:
#mysqldump -u username -ppassword database_name > FILE.sql

e.g #mysqldump -u root -phahahaha DENVDB > FILE.sql

FILE.sql would be generated in /root. Copy the file to Windows Desktop just in case.


b) Type the following command in Putty Konsole or SSH in Bioslax Konsole (server side):
#mysql -u username -ppassword database_name < FILE.sql

e.g #mysql -u benjamin -phahahahah denvdb < FILE.sql

Justin has created the database as denvdb.

Got an error message:
ERROR 1045 (28000): Access denied for user 'benjamin'@'localhost' (using password: YES)

Justin has enabled CREATE and ALTER access for my account, so it works now.


Tips from Justin:

1. don't type your password on to a command line ... people can just see what you are typing by using commands such as finger or who
e.g. instead of typing ...
#mysqldump -u username -ppassword DENVDB > FILE.sql

type
#mysqldump -u username -p DENVDB > FILE.sql


then the system will prompt you for a password and then only you type in there (it won't be shown on the screen as you type, so no worry)
also, by typing your pass on the command line, others can easily just check your ~/.bash_history file to see what you have typed and hence get your pass


2. in Windows, it is not case sensitive since it doesn't have much concept of case sensitivity ... in Linux, UNIXes etc
yes it matters. So, preferably you just use small case for most things (if possible) ... and try not to use spaces in between names as well ...
it will make a lot of things easy .. besides, you need less effort following this simple convention.

3. before you try to do loading and stuffs, you can always check with account login first.
just login to proline and type

mysql -u benjamin -p


this way you can test to see if you can even login or not in the first place ... and if yes, then you can narrow down what went wrong.
Anyway, assuming that you managed to get in as what I've done using ur account, you will see there are two databases ...
one is denvdb the other is information_schema. The latter is a system default so ignore that.


with that, then next thing is ... in your FILE.sql ... do you have a statement like


use denvdb;


right at the top of the file ?
if you don't , then you have to do


mysql -u benjamin -p denvdb < file.sql

No comments:

Post a Comment