Mysql import database

5.9k Views Asked by At

I am new to mysql.I got a .sql file which I needed to import,so I searched online and got the below command.It worked perfectly.

C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p test3 < test3.sql

But when I said use test3 from mysql command line client,it gave me this error :

ERROR 1049 (42000): Unknown database 'test3'

Am I missing some step?

3

There are 3 best solutions below

0
On BEST ANSWER

First of all you would need to create the database in MYSQL so that once you use the command, it is able to locate the name of the database

You can create the table using MYSQL developer tool or using the command line and then you can execute

mysql -u root -p test3 < test3.sql
4
On

The database needs to exist, and be called from the command line using -D

so within MySQL try;

mysql> create database test3;

and back at the command prompt, try;

C:\Program Files\MySQL\MySQL Server 5.6\bin>mysql -u root -p -D test3 < test3.sql
0
On

You have not created test3 database yet. First create a test3 database & then try to import.