0

For exporting I tried,

mysqldump -u root DB1 -R > E:\Java\AkshayProject\Dump\DBbackup.sql

It worked !

For importing I tried,

mysqldump -u root DB2 -R < E:\Java\AkshayProject\Dump\DBbackup.sql

Result :

-- MySQL dump 10.16 Distrib 10.1.38-MariaDB, for Win64 (AMD64)

-- Host: localhost Database: demo


-- Server version 10.1.38-MariaDB

/*!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 */;

-- -- Dumping routines for database 'db2' -- /*!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 2019-10-11 21:22:56

I checked, nothing is imported in DB2

How to import database with all tables, views, procedures and functions?

  • Check the SQL dump for `USE DB1` ? `CREATE TABLE DB1. .... ` things? – Raymond Nijland Oct 11 '19 at 16:08
  • ... as it should be not possible that `mysqldump -u root DB1 -R > E:\Java\AkshayProject\Dump\DBbackup.sql` command work and the second `mysqldump -u root DB2 -R > E:\Java\AkshayProject\Dump\DBbackup.sql` .. So most likely there as `DB1` database references used in the import? – Raymond Nijland Oct 11 '19 at 16:10
  • Possible duplicate of [How do I import an SQL file using the command line in MySQL?](https://stackoverflow.com/questions/17666249/how-do-i-import-an-sql-file-using-the-command-line-in-mysql) – nbk Oct 11 '19 at 16:11
  • .. also i do not understand the result ??? Do you mean you got a error when running `mysqldump -u root DB2 -R < E:\Java\AkshayProject\Dump\DBbackup.sql` ? – Raymond Nijland Oct 11 '19 at 16:13
  • @nbk Other answers only talks about importing tables. Their methods don't work for importing and exporting views, functions, procedures etc. – अक्षय परूळेकर Oct 11 '19 at 16:43
  • @RaymondNijland Whatever output I got on command prompt, I've mentioned it in question description. When I checked database DB2, it was empty. Nothing was imported in it – अक्षय परूळेकर Oct 11 '19 at 16:44
  • I opened the exported file using mysql workbench. It imported all tables, views, functions and procedures when I run that file in mysql workbench. How can I do it using command line? – अक्षय परूळेकर Oct 11 '19 at 16:48
  • There are a lot of options for mysqldumpfor at least routines is necessary see all options for mysqldump https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html – nbk Oct 11 '19 at 17:40
  • why following command not working? mysqldump -u root DB2 -R < E:\Java\AkshayProject\Dump\DBbackup.sql – अक्षय परूळेकर Oct 11 '19 at 18:36

0 Answers0