I'm trying to understand "rename" a database by possibly modifying the dump file format
I've tried altering the DROP IF and CREATE and USE statements
-- MySQL dump 10.13 Distrib 5.7.21-20, for Linux (x86_64)
--
-- Host: localhost Database: music
-- ------------------------------------------------------
-- Server version 5.7.21-20-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 */;
At the moment it works, but I'm curious if line number 3
-- Host: localhost Database: music
Has any affect on import -- so as it were:
mysql albums < music_db.sql
Does it end up in the DB Albums?
Related
I've created a copy of a database and changed the collation and charset to utf8mb4 (originally it was latin1), then used mysqldump to create a script for a Flyway database migration.
When I run the following script
-- MySQL dump 10.13 Distrib 5.5.62, for Win64 (AMD64)
--
-- Host: localhost Database: feedback
-- ------------------------------------------------------
-- Server version 8.0.15
/*!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 utf8mb4 */;
/*!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 data for table `COMPONENT_GROUP`
--
LOCK TABLES `COMPONENT_GROUP` WRITE;
/*!40000 ALTER TABLE `COMPONENT_GROUP` DISABLE KEYS */;
INSERT INTO `COMPONENT_GROUP` VALUES ('AAAB','AAA - MOTOR','LUBRIFICAÇÃO DO MOTOR','LUBRIFICAÇÃO DO MOTOR',NULL,NULL,20181219,1)
UNLOCK TABLES;
/*!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-05-22 13:07:38
flyway shows messages like these:
WARNING: DB: Invalid utf8 character string: 'C7C34F' (SQL State: HY000 - Error Code: 1300)
WARNING: DB: Incorrect string value: '\xC3O FUN...' for column 'claimed_name_pt' at row 10 (SQL State: HY000 - Error Code: 1366)
When I run the dump script using tools like SQLyog and MySQL Workbench the data is correctly inserted, so how can I fix that for Flyway?
Found the missing part to fix the migration issue. I had to add encoding settings to the Flyway's connection string:
FLYWAY_URL="jdbc:mysql://${db_instance.default.address}:3306/${mysql_database.db-app.name}?characterEncoding=UTF-8&useUnicode=true"
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
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
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
i am trying to backup my database using mysqldump
code
exec('D:\wamp\bin\mysql\mysql5.6.17\bin\mysqldump -h'.$HOSTNAME.' -u'.$DBUSER.' -p'.$DBPASS.' dbname -t tablename > '.$mysqlExportPath.' --log-error="DumpError.txt');
and i got following output
-- MySQL dump 10.13 Distrib 5.6.17, for Win32 (x86)
--
-- Host: localhost Database: database name
-- ------------------------------------------------------
-- Server version 5.6.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 */;
Dump Error
mysqldump: Couldn't find table: "13:44:43.sql"
1.problem is mysqldump not writing table structure and data in output.
2.table name is display as 13:44:43.sql where as my table name is like abc.
3.if i run same code with same tablename again table name in dump error changes with other numeric ex. next time it is 13:45:08.sql.
plz help i am not able to find that numeric table name problem any ware.
solved.
date(); have space between date and time so time was taken as table name due to space.