Add Database routines
parent
5d5822bcf3
commit
a221240b0f
1 changed files with 46 additions and 0 deletions
46
Database.md
Normal file
46
Database.md
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue