LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Not able to import MySQL database using SSH (https://www.linuxquestions.org/questions/linux-server-73/not-able-to-import-mysql-database-using-ssh-4175419974/)

dreamcoder 08-02-2012 09:00 AM

Not able to import MySQL database using SSH
 
Hi Guys,

Today I was importing my wordpress database (from shared hosting) to my new VPS having nginx, mysql and php on Ubuntu 11.10

I ftp'd my wordpress database(wp_db.sql) to my VPS and then I cd'd into the directory containing the wp_db.sql, now I created a new database in mysql named wordpress using phpmyadmin and then I ran the following command to import wp_db.sql into wordpress database:

Code:

mysql -u root -p wordpress < wp_db.sql
I was prompted for password which I entered and got the following error:

Quote:

ERROR 1064 (42000) at line 1: 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 'mysql Ver 14.14 Distrib 5.1.63, for debian-linux-gnu (i686) using readline 6.2
' at line 1
I don't know what syntax problem is causing this error, I tried many versions of the above command but everytime I get the same error

Please Help

Thanks :)

TenTenths 08-02-2012 09:44 AM

It's not your command like that's causing the problems it's something in your wp_db.sql file that has a command that's wrong.

lithos 08-02-2012 10:04 AM

[QUOTE=dreamcoder;4744108]

I was prompted for password which I entered and got the following error:
Quote:

... at line 1: You have an error in your SQL syntax; ...[/code]

Can you post the first few lines of your "wp_db.sql"
to see what's in there.

dreamcoder 08-02-2012 10:19 AM

[QUOTE=lithos;4744184]
Quote:

Originally Posted by dreamcoder (Post 4744108)

I was prompted for password which I entered and got the following error:


Can you post the first few lines of your "wp_db.sql"
to see what's in there.


wp_db.sql contains many wp tables, I don't know which table has the wrong syntax causing this error

Is there any way to find it out ??

lithos 08-03-2012 01:58 AM

Did you dump the database to file ?

then you get a "text" file, so post first few lines... (# head wp_db.sql)

dreamcoder 08-03-2012 06:49 AM

Quote:

Originally Posted by lithos (Post 4744714)
Did you dump the database to file ?

then you get a "text" file, so post first few lines... (# head wp_db.sql)


Thanks a lot bro, the problem was indeed in the .sql file

I re-exported the full database (from my shared hosting) as .sql using a plugin - backupwordpress and then ftp'd this exported database to my vps and then ran the command:
Quote:

mysql -u root -p wordpress < new_db.sql
, it imported the db perfectly!!

I think the problem arised because phpmyadmin (on my shared hosting) was not exporting the 500MB database properly (still don't know why)


Anyways, thanks a lot for your hint mate :)

lithos 08-03-2012 08:50 AM

Great,
I'm glad to see you worked it out.
Thanks for posting back.


All times are GMT -5. The time now is 12:28 PM.