MYSQLDUMP : Errors while restoring database - mysql

I created a backup of mysql database from my live site using mysqldump and downloaded the SQL file (~960MB). I've a local install of MariaDB and I tried importing the database again using mysqldump. I am getting following error:
-- MySQL dump 10.16 Distrib 10.2.10-MariaDB, for osx10.13 (x86_64)
--
-- Host: localhost Database: original
-- ------------------------------------------------------
-- Server version 10.2.10-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 */;
/*!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 2017-12-01 8:27:08
I'm not allowed to make any changes to the live DB and would really appreciate if there's a way to import this DB successfully to my local DB.
Thank you in advance for your cooperation.

As noted in comments,
That's not an error, it's just comments in the dump file.
Additionally,
You don't use mysqldump to import, only to export. You use mysql < filename to import
From this question: MariaDB i am not able to import this dump file
You import the dump like so:
mysql -u root -p --database=db_name < dumpfile.sql

Related

mysqldump restoring a database backup into a empty database using terminal ubuntu

steps:
got bananas database backup:
mysqldump -u root -p bananas > /var/www/site.com/bananas_backup.sql
I created a new empty datase;
mysql> CREATE DATABASE bananas2019;
now appplying bananas backup into bananas 2019;
mysqldump -u root -p bananas2019 < bananas_backup.sql
got this:
-- MySQL dump 10.13 Distrib 5.7.24, for Linux (x86_64)
--
-- Host: localhost Database: bananas2019
-- ------------------------------------------------------
-- Server version 5.7.24-0ubuntu0.18.04.1
/*!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 */;
/*!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 2018-11-30 19:16:05
I went to check my database and still empty with no data why?
my backup it is in the right directory and has data, already checked this.
what i am doing wrong?
mysqldump just dumps data, it's not used for importing. For that you can use mysql:
mysql -u root -p bananas2019 < bananas_backup.sql

mysqldump dump completed but data not loaded

Im trying to dump the a sql file and get the below results..It says "dump completed" but the database.
ps#Pds-MacBook-Pro robe-code $ mysqldump -u ninja -p robe<shgp_prod_latest.mysql
Enter password:
-- MySQL dump 10.13 Distrib 5.7.11, for osx10.9 (x86_64)
--
-- Host: localhost Database: Krobe
-- ------------------------------------------------------
-- Server version 5.7.11
/*!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 */;
/*!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 2017-01-26 17:51:21
Once I had same problem, when I was trying to import Database into mariaDb.
There are TWO reasons for this output:
One:
Problem here with your command is, mysqldump is used export database not import.
use mysql instead.
also we use < to import and > to export.
TWO:
it also shows same output if .sql size is 0byte.
The correct output redirection operator would be > and not <

How do i backup mysql in Grails3

I don't know does grails3 have the default api to dump my database.
But when I execute the shell command mysqldump -u root -ppass *** >> /***.sql in groovy and the cmd is not work with some message from execute().text
-- MySQL dump 10.13 Distrib 5.7.14, for osx10.11 (x86_64) -- -- Host: localhost Database: grailstest -- ------------------------------------------------------ -- Server version 5.7.14 /*!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 */;
OK,I solved the problem, just execute the 'musqldump' command without '> *.sql', then redirect the Process.inputStream to another .sql file

Execute sql dump file

I'm trying to create the table and add all the records present in the .sql dump file..
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqldump -u root -p org < database_name.sql
Enter password: ****
-- MySQL dump 10.13 Distrib 5.7.15, for Win64 (x86_64)
-- Host: localhost Database: org
-- ------------------------------------------------------
-- Server version 5.7.15-log
/*!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 */;
/*!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 2016-12-24 23:38:01
after completing the above command..i am not seeing any table in my database.
[no tables in the database][1]
https://i.stack.imgur.com/1OhTU.png
thanks
Instead of mysqldump use mysql instead.
mysql -u root -p org < database_name.sql

mysqldump generating empty tables

I am trying to restore a database backup to a new database, and it didn't add tables. I use MySQL 5.5.17 for MacOSX 10.6 (Lion).
I saved the database called "mydatabase" with the following command:
/usr/local/mysql/bin/mysqldump --add-drop-table --user=root --password=mypass mydatabase > /Users/Me/Desktop/backup.sql
And I tried to restore to another database called "temp", with this command:
/usr/local/mysql/bin/mysqldump --verbose --user=root --password=mypass temp < /Users/Me/Desktop/backup.sql
Here the message after did the restore command:
-- MySQL dump 10.13 Distrib 5.5.17, for osx10.6 (i386)
--
-- Host: localhost Database: temp
-- ------------------------------------------------------
-- Server version 5.5.17
/*!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 */;
-- Disconnecting from localhost...
/*!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 2011-11-19 0:07:09
Mysqldump is for creating backup, not for restoring. To restore use mysql : mysql -u[username] -p[password] [database_name] <path_to_your_backup. Database should be created in advance.
Also, you may probably need to add --routines to mysqldump, by default it doesn't include stored procedures/functions.