From a221240b0f02ba51da4c7331539d1f5f782bd065 Mon Sep 17 00:00:00 2001 From: coderkun Date: Fri, 28 Oct 2016 23:04:07 +0200 Subject: [PATCH] Add Database routines --- Database.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Database.md diff --git a/Database.md b/Database.md new file mode 100644 index 0000000..30dc45d --- /dev/null +++ b/Database.md @@ -0,0 +1,46 @@ +# Database + +## Routines + +### Create + + CREATE DATABASE `z` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci; + CREATE USER 'z'@'%' IDENTIFIED BY 'legendofZ'; + GRANT ALL PRIVILEGES ON z.* TO 'z'@'%' + +### Export + +Export database structure only: + + $ mysqldump --routines --triggers --no-data -u z -p z | sed 's/ AUTO_INCREMENT=[0-9]*\b//' > create.sql + +Export data only: + + $ mysqldump --no-create-info --skip-triggers --complete-insert -u z -p z > import.sql + +### Import + +Import database structure: + + $ mysql -u z -p z < create.sql + + +Import data: + + $ mysql -u z -p z < import.sql + + +_Note: You may need to delete all triggers before importing data and recreate them after the import (using triggers.sql)!_ + +### Update + +There is currently no official database update procedure. As soon as we hit version 1.0 we will provide update scripts. + +However the following routine—which is a combination of the commands above—appears to be sufficient: + + $ mysqldump --no-create-info --skip-triggers --complete-insert -u z -p z > ~/data.sql + $ mysql -u z -p z < db/create.sql + $ mysql -u z -p z < db/drop.sql + $ mysql -u z -p z < ~/data.sql + $ mysql -u z -p z < db/procedures.sql + $ mysql -u z -p z < db/triggers.sql