mysqldump doesn't create tables or import any data
Solution 1
You want to run the dump through the mysql client.
Example:
mysql -uroot -p testimport < database.dump
Solution 2
Because when you dump data (Backup) you used "mysqldump" :
mysqldump -u user -p Database_name > SQL_dump_file.sql
But when restore data into database you need to use only "mysql":
mysql -u user -p Database_name < SQL_dump_file.sql
Related videos on Youtube
Comments
-
George over 1 year
I am trying to import a mysqldump into a new database. When I run:
mysqldump -umydbuser -p --database testimport < database.dump
I get the following output:
Enter password: -- MySQL dump 10.11 -- -- Host: localhost Database: testimport -- ------------------------------------------------------ -- Server version 5.0.75-0ubuntu10.3 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Current Database: `testimport` -- CREATE DATABASE /*!32312 IF NOT EXISTS*/ `testimport` /*!40100 DEFAULT CHARACTER SET latin1 */; USE `testimport`; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -- Dump completed on 2010-03-09 17:46:03
However, when I look at the testimport database, there are no tables and no data. Even if I export a working database by:
mysqldump -umydbuser -p --database workingdatabase > test.sql
and then import:
mysqldump -umydbuser -p --database testimport < test.sql
I get the same output, but nothing is imported into the
testimport
database. I don't see any errors in the output and it is using the proper database. If I tail the exported .sql file, I see the create statements for all tables and the inserts for all data. Why isn't this data importing? Is there any additional logging I can see? -
Warner over 8 yearsDifferent tools for different purposes, Josh.
-
dortegaoh about 5 yearsYou can't import data with
mysqldump
, it's an export only tool.mysql
is for import.