From 70878b936ab23c09919f611b419c932aeceec331 Mon Sep 17 00:00:00 2001 From: pdiogoantunes Date: Thu, 22 Jun 2017 10:26:54 +0200 Subject: [PATCH] Renommer une base --- HowtoMySQL.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/HowtoMySQL.md b/HowtoMySQL.md index 449c8697..76a0eda7 100644 --- a/HowtoMySQL.md +++ b/HowtoMySQL.md @@ -345,6 +345,16 @@ GRANT ALL PRIVILEGES ON `base`.* TO 'accesbase'@'localhost' # mysql -e "select * from information_schema.user_privileges;" ~~~ +### Renommer une base + +- Créer une base vide +- Renommer toutes les tables vers cette dernière (utilisation script ci-dessous) + +~~~ +BASE_FROM=bf_griffe16; BASE_TO=bf_griffe16_old +for table in $(mysql -e "use $BASE_FROM; show tables\G;" | grep -v '^\*\*\*' | cut -d':' -f2 | sed 's/^ //'); do echo $table; mysql -e "RENAME TABLE ${BASE_FROM}.${table} TO ${BASE_TO}.${table};"; done +~~~ + ## Administration On crée une base de données et un utilisateur associé :