0

I am trying to import database file through cmd because its size is too big.

I have tried following command,

/opt/lampp/bin $ mysql.exe -u root -p db_name <~ filename.sql

but it gives

mysql Ver 14.14 Distrib 5.5.43, for debian-linux-gnu (x86_64) using readline 6.3 Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

and open help of mysql command.

I cant get the problem. Please help

6
  • You have a ~ lost in there,remove it Commented Jul 6, 2015 at 13:27
  • m using it for path of file.sql I have kept my file at home directory only. Commented Jul 6, 2015 at 13:30
  • so if I remove ~ then it will give error - No such file or directory. Commented Jul 6, 2015 at 13:30
  • Then use the absolute path Commented Jul 6, 2015 at 13:31
  • I tried and it is giving different error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Commented Jul 6, 2015 at 13:35

3 Answers 3

1

Use the following cmd, make sure of the sql file path is correct, as well as you do not have any spaces after -:

spawn mysql -u dbUser -h hName -pdbPass dbName < db_schema.sql
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for the help. But it is giving error like, Python error: <stdin> is a directory, cannot continue
what tool are you using to run this command? Are you running it within python interpreter? Make sure you are using the Linux terminal
@user3890150: python error thrown does not seem to be an SQL error. Your py code must be having errors.
m running in terminal only. what is the solution ? I still cnt get.
Try running an SQL script with a simple insert of only one line, just for testing. Make sure of the full path being used in your script. Try running the command without spawn.
|
0

Use the full path of the SQL file filename.sql

Comments

0

1.Log into the mysql terminal and create database say dbName (Make sure that this db name corresponds to the db you are importing)

$mysql -u dbUser -p 
mysql> create database dbName;

Here dbUser must be replaced with you db user name or 'root'(which is the most probable one used) and dbName must be replaced with your database name.

Also check if the database is created using following command

mysql>show databases; 

2.Exit to the terminal and give the command:

mysql>exit

$mysql -u dbUser -p dbName < '/full/path/to/sql_file.sql' 

3.Enter the sql prompt and see if the database is there, and also check if all the db is imported.

$mysql -u dbUser -p 
mysql> show databases;
mysql> use dbName;
mysql> show tables;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.