DiigIT | IT Community
No Profile Image
Welcome Guest
New User? Register | Login

Importing SQL files from SSH

By: rekha singh | 25 May 2010 11:36 am

 I'm trying to import a SQL file full of UPDATE statements to my database. My web host is absolutely no help at all. I've done this before and someone helped me find a command that worked. But four months later, I've obviously forgotten.

 
This is what they're suggesting that I use: mysql -p -u username database_name < file.sql
 
So, I log in, cd to the directory where the file is stored, and run the above command. It asks for my password and nothing happens.
 
Am I doing something wrong?
 

Comments

 Are you trying to move or copy a database from one machine to another?

 
If so this may help -
 
to back up or transfer a database
open terminal window
$ mysqldump -u username - p databasename > backupfilename.sql
type password when prompted
 
to install on another pc
copy the file across
open terminal window
cd to directory containing the file
$ mysql -u username -p
type password when prompted
mysql> use databasename;
note - if the database does not exist you need to create it with
mysql> create database databasename;
mysql> source backupfilename.sql;
 
this will create all tables, views and load all of the data from the old database
 
Hope that helps
 
By: rekha singh | 25 May 2010

Leave a comment

Enter the text in the image
img
Can't read?
Type the characters you see in the picture below.


Close Move