Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: importing database.sql
PostPosted: Tue Jan 19, 2010 10:59 am 
Offline
Senior Newbie

Joined: Tue Jan 19, 2010 10:11 am
Posts: 9
Newb here. I'm slowly getting the hang of the terminal interface. I'm stuck, though. I have a 70mb sql file (databaseBU.sql) that I need to import into MySql. The database has been created (MyDatabase).

I've uploaded the file to:
/srv/www/mydomain.com/public_html/databaseBU.sql

questions:
1) what is the command I should run once inside mysql/terminal
2) how long should 70mb take to import?

Running Ubuntu Hardy.

Thanks


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 12:34 pm 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
Code:
cat /srv/www/mydomain.com/public_html/databaseBU.sql | mysql


Quote:
how long should 70mb take to import?


It depends.


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 12:44 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
This is a message from the SOCIETY FOR THE PREVENTION OF CAT PIPING.

Stop piping cats:

Code:
mysql < /srv/www/mydomain.com/public_html/databaseBU.sql


See this link for more information.

... we now return you to your regular programming :-) (note: you might need to add --user=username, --password, and the database name to the mysql command as required.)


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 12:56 pm 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
That link is about the performance profile of grep, which has nothing to do with what's going on here. There won't be any speed difference for this operation. But certainly use whatever CLI style you like!


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 1:10 pm 
Offline
Senior Newbie

Joined: Tue Jan 19, 2010 10:11 am
Posts: 9
hoopycat wrote:
Code:
mysql < /srv/www/mydomain.com/public_html/databaseBU.sql


OK, thanks. so i'm at the mysql cursor and this is what i enter:

Code:
 mysql -u username -p password MyDatabase < /srv/www/mydomain.com/public_html/databaseBU.sql;


you have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '< /srv/www/...


Last edited by embarkadero on Tue Jan 19, 2010 1:24 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 1:24 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
That new cursor means that you have entered an incomplete SQL command, so MySQL is waiting for you to complete it.

The problem might have to do with the contents of the file, or it might have to do with the syntax you're using. Try this: Don't specify the password on the command line. Just skip the password, and MySQL will ask you for it.

Code:
mysql -u username -p MyDatabase < /srv/www/mydomain.com/public_html/databaseBU.sql


The above command would look as if it's supplying "MyDatabase" as the password, but in fact it's not. Crazy MySQL command line ;)


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 1:27 pm 
Offline
Senior Newbie

Joined: Tue Jan 19, 2010 10:11 am
Posts: 9
hybinet wrote:
That new cursor means that you have entered an incomplete SQL command, so MySQL is waiting for you to complete it.

The problem might have to do with the contents of the file, or it might have to do with the syntax you're using. Try this: Don't specify the password on the command line. Just skip the password, and MySQL will ask you for it.

Code:
mysql -u username -p MyDatabase < /srv/www/mydomain.com/public_html/databaseBU.sql


The above command would look as if it's supplying "MyDatabase" as the password, but in fact it's not. Crazy MySQL command line ;)


thanks for the reply, now I'm getting an error in my SQL syntax. hmmm... I wonder if something happened when I FTP'd the *.sql file.


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 3:52 pm 
Offline
Senior Newbie

Joined: Tue Jan 19, 2010 10:11 am
Posts: 9
Still not working. I tried installing phpmyadmin, thinking that might make it easier. Alas, no. Now that it is installed, I can't seem to access it. argh. keeping the faith.


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 4:11 pm 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
Wait, did you say you're running that command from the mysql prompt? It needs to be run from the shell.


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 4:15 pm 
Offline
Senior Member
User avatar

Joined: Sun Dec 27, 2009 11:12 pm
Posts: 1038
Location: Colorado, USA
Maybe double check a few things.

mysql -u root -p

Do you successfully log in?

show databases;

Does MyDataBase show up?

If the above works, try cd'ing to the directory your .sql file is in, then run the import command without the path.

# mysql -u username -p database_name < FILE.sql


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 4:26 pm 
Offline
Junior Member

Joined: Wed Jan 23, 2008 9:49 pm
Posts: 34
embarkadero wrote:

OK, thanks. so i'm at the mysql cursor and this is what i enter:

Code:
 mysql -u username -p password MyDatabase < /srv/www/mydomain.com/public_html/databaseBU.sql;



You should type that at the shell command line not at the mysql command line.


Top
   
 Post subject:
PostPosted: Tue Jan 19, 2010 4:29 pm 
Offline
Senior Newbie

Joined: Tue Jan 19, 2010 10:11 am
Posts: 9
Xan wrote:
Wait, did you say you're running that command from the mysql prompt? It needs to be run from the shell.


YES! This worked. Thank you to everyone who took the time to respond.


Top
   
 Post subject: Re:
PostPosted: Sat Sep 15, 2012 6:59 pm 
Offline
Senior Newbie

Joined: Sun Aug 19, 2012 4:55 am
Posts: 11
atourino wrote:
You should type that at the shell command line not at the mysql command line.


Thank the lord!


Top
   
PostPosted: Sat Sep 15, 2012 7:11 pm 
Offline
Senior Member
User avatar

Joined: Fri Oct 24, 2003 3:51 pm
Posts: 965
Location: Netherlands
Necropost!

_________________
/ Peter


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group