Reputation: 575
The sql file named:bag.sql
in /var/www/html/web
(/var/www/html/web/bag.sql)
the current directory is [localhost web]
i used mysql -uusername -p databasename > bag.sql
then let me input the password. i wait for long time, it doesn't show ok. why? how to import the database to mysql under centos.
Upvotes: 2
Views: 21559
Reputation: 134
Connect to mysql database server
$ mysql -uusername -ppassword
Check database exists are not
$ show databases;
If not create the same
mysql>create database mydb;
note: mydb is database name(Give your own).
Check again for the database follow step 2.
exit
Import data to mydb(your own) database
$ mysql -uusername -ppassword mydb < bag.sql
note: your bag.sql is in the current directory from where you are executing the above command
Check for imported data.
YES FOR LONG WAIT YOU NEED TO CHECK YOUR BAG.SQL FILE SIZE.
Symbol '$' is shell prompt
Upvotes: 2
Reputation: 4060
Let me offer up another alternative using pv
pv /path/to/file.sql | mysql -uUSERNAME -pPASSWORD -D DATABASE_NAME
This will show you a progress indicator for the import. If you have never used pv
it is a piper viewer tool in linux.
Upvotes: 1
Reputation:
if you have already created database then use below steps to import data from .sql file
tell which database to use:
use databasename;
Now give the source file path
source /var/www/html/web/bag.sql;
Upvotes: 10
Reputation: 1101
you're using the wrong redirection operator. >
is used for sending the output to a file, not taking input from a file. Use <
.
Upvotes: 0
Reputation: 111349
You need mysql -uusername -p databasename < bag.sql
.
< Means "get the program's input from this file"
> Means "write the program's output to this file"
Upvotes: 4