Link to home
Create AccountLog in
Avatar of dolythgoe
dolythgoe

asked on

mysql import from a .zip on Ubuntu

Hello all,

Please could someone help me with the command I need in Ubuntu 11 CLI for importing a .zip into the mysql?

The .zip file contains a CREATE DATABSE.

Cheers
Avatar of Nem Schlecht
Nem Schlecht
Flag of United States of America image

'unzip' your file and then feed the resulting SQL statements into a 'mysql' connection (assuming you have CREATE DATABASE privileges).

Let's say your ZIP file contains a single file, 'dbscheme.sql'.  Extract that out of the ZIP file and then run, on the command line:
mysql --username=mysql_username -p < dbscheme.sql

Open in new window

And enter your password when prompted.  This assumes that you're connecting to MySQL on your localhost, if not, just add '-h hostnmae'.
Avatar of dolythgoe
dolythgoe

ASKER

Thanks for that but isn't there a way to do it straight from zip? ie. unzip and import in one statement?
ASKER CERTIFIED SOLUTION
Avatar of Nem Schlecht
Nem Schlecht
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Great thanks for your help :)