Injection en local de votre ancienne BDD et “split” de celle-ci
Se connecter an local via la console au client MySQL sous MAMP. Par défaut, le couple utilisateur:mot de passe est root:root
# Se connecter an LOCAL via la console au client MySQL
/Applications/MAMP/Library/bin/mysql -u root -p
# Se connecter an local via la console au client MySQL
/Applications/MAMP/Library/bin/mysql -u root -p
Créer une BDD
# Créer une BDD
CREATEDATABASE migratiowp1;
# Créer une BDD
CREATE DATABASE migratiowp1;
Utiliser cette BDD vide nouvelle créée
# Selectionner la BDD
USE migratiowp1;
# Selectionner la BDD
USE migratiowp1;
Injecter le contenu de votre ancienne BDD
# Injecter le contenu
SOURCE/Users/nom-utilsateur/Documents/chemin-vers-les-fichiers-SQL/sql_fichier/dump_sql_migratiowp1.sql;
# Injecter le contenu
SOURCE /Users/nom-utilsateur/Documents/chemin-vers-les-fichiers-sql/sql_fichier/dump_sql_migratiowp1.sql;
Pour l’exemple, nous avons décidé de migrer un blog sous WP
# Export de la TABLE wp_posts
/Applications/MAMP/Library/bin/mysqldump -c -u root -p migratiowp1 wp_posts >/Users/nom-utilsateur/Documents/chemin-vers-les-fichiers-SQL/sql_fichier/wp_posts_migratiowp1.sql
# Export de la table wp_posts
/Applications/MAMP/Library/bin/mysqldump -c -u root -p migratiowp1 wp_posts > /Users/nom-utilsateur/Documents/chemin-vers-les-fichiers-sql/sql_fichier/wp_posts_migratiowp1.sql
# Export de la TABLE wp_terms
/Applications/MAMP/Library/bin/mysqldump -c -u root -p migratiowp1 wp_posts >/Users/nom-utilsateur/Documents/chemin-vers-les-fichiers-SQL/sql_fichier/wp_terms_migratiowp1.sql
# Export de la table wp_terms
/Applications/MAMP/Library/bin/mysqldump -c -u root -p migratiowp1 wp_posts > /Users/nom-utilsateur/Documents/chemin-vers-les-fichiers-sql/sql_fichier/wp_terms_migratiowp1.sql
Conclusion : Il ne vous reste plus qu’à exporter toutes les tables les unes après les autres. Vous devriez vous retrouver avec une collection de fichiers .sql de taille inférieure à la BDD complète et donc avoir toutes les chances de passer sous les fourches caudines de l’import sous PhpMyadmin de votre espace mutualisé. Un conseil avant de vous livrer à l’import, certaines tables sont dépendantes entre elles donc assurez-vous de bien avoir sous les yeux le schéma relationnel de votre BDD
Pour mémoire, les mêmes commandes servent d’ailleurs au backup des BDD
# Utiliser le client mysqldump pour faire un backup de la TABLE hecube_demo_users dans la base hecube_demo
/Applications/MAMP/Library/bin/mysqldump -c -u root -p hecube_demo hecube_demo_users >/Users/username/rep-1/he3_blog/datas/hecube_demo_users.mysqldump-1.SQL
# Utiliser le client mysqldump pour faire un backup de la TABLE hecube_demo_users dans la base hecube_demo
/Applications/MAMP/Library/bin/mysqldump -c -u root -p hecube_demo hecube_demo_users > /Users/username/rep-1/he3_blog/datas/hecube_demo_users.mysqldump-1.SQL
Pour mémoire, quelques commandes toujours utiles
# voir toutes les BDD
SHOWDATABASES;
# voir toutes les BDD
SHOW DATABASES;
# Supprimer une BDD
DROPDATABASE migratiowp1;
# Supprimer une BDD
DROP DATABASE migratiowp1;
Pour plus d’informations, sur la gestion des BDD MySQL, vous pouvez jeter un oeil à cet article de notre blog.
Extrait de l’export de la table wp_posts via la client MySQL sous MAMP
# Utiliser le client mysqldump pour faire un backup de toutes TABLES dans une base hecube_demo
/Applications/MAMP/Library/bin/mysqldump -c -u root -p hecube_demo hecube_demo_users >/Users/username/rep-1/he3_blog/datas/hecube_demo.mysqldump-FULL.SQL
# Utiliser le client mysqldump pour faire un backup de toutes TABLES dans une base hecube_demo
/Applications/MAMP/Library/bin/mysqldump -c -u root -p hecube_demo hecube_demo_users > /Users/username/rep-1/he3_blog/datas/hecube_demo.mysqldump-FULL.SQL
-- MySQL dump 10.13 Distrib 5.1.37, for apple-darwin8.11.1 (i386)---- Host: localhost Database: migratiowp1-- -------------------------------------------------------- Server version 5.1.37/*!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 */;
---- Table structure for table `wp_posts`--DROPTABLEIFEXISTS`wp_posts`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATETABLE`wp_posts`(`ID`BIGINT(20)UNSIGNEDNOTNULLAUTO_INCREMENT,`post_author`BIGINT(20)UNSIGNEDNOTNULLDEFAULT'0',`post_date` datetime NOTNULLDEFAULT'0000-00-00 00:00:00',`post_date_gmt` datetime NOTNULLDEFAULT'0000-00-00 00:00:00',`post_content` longtext NOTNULL,`post_title` text NOTNULL,`post_excerpt` text NOTNULL,`post_status`VARCHAR(20)NOTNULLDEFAULT'publish',`comment_status`VARCHAR(20)NOTNULLDEFAULT'open',`ping_status`VARCHAR(20)NOTNULLDEFAULT'open',`post_password`VARCHAR(20)NOTNULLDEFAULT'',`post_name`VARCHAR(200)NOTNULLDEFAULT'',`to_ping` text NOTNULL,`pinged` text NOTNULL,`post_modified` datetime NOTNULLDEFAULT'0000-00-00 00:00:00',`post_modified_gmt` datetime NOTNULLDEFAULT'0000-00-00 00:00:00',`post_content_filtered` text NOTNULL,`post_parent`BIGINT(20)UNSIGNEDNOTNULLDEFAULT'0',`guid`VARCHAR(255)NOTNULLDEFAULT'',`menu_order`INT(11)NOTNULLDEFAULT'0',`post_type`VARCHAR(20)NOTNULLDEFAULT'post',`post_mime_type`VARCHAR(100)NOTNULLDEFAULT'',`comment_count`BIGINT(20)NOTNULLDEFAULT'0',PRIMARYKEY(`ID`),KEY`post_name`(`post_name`),KEY`type_status_date`(`post_type`,`post_status`,`post_date`,`ID`),KEY`post_parent`(`post_parent`),KEY`post_author`(`post_author`)) ENGINE=MyISAM AUTO_INCREMENT=2743DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
---- Dumping data for table `wp_posts`----- les données viennent ensuite...
-- MySQL dump 10.13 Distrib 5.1.37, for apple-darwin8.11.1 (i386)
--
-- Host: localhost Database: migratiowp1
-- ------------------------------------------------------
-- Server version 5.1.37 /*!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 */; --
-- Table structure for table `wp_posts`
-- DROP TABLE IF EXISTS `wp_posts`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `wp_posts` (
`ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`post_author` bigint(20) unsigned NOT NULL DEFAULT '0',
`post_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_date_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_content` longtext NOT NULL,
`post_title` text NOT NULL,
`post_excerpt` text NOT NULL,
`post_status` varchar(20) NOT NULL DEFAULT 'publish',
`comment_status` varchar(20) NOT NULL DEFAULT 'open',
`ping_status` varchar(20) NOT NULL DEFAULT 'open',
`post_password` varchar(20) NOT NULL DEFAULT '',
`post_name` varchar(200) NOT NULL DEFAULT '',
`to_ping` text NOT NULL,
`pinged` text NOT NULL,
`post_modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_modified_gmt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`post_content_filtered` text NOT NULL,
`post_parent` bigint(20) unsigned NOT NULL DEFAULT '0',
`guid` varchar(255) NOT NULL DEFAULT '',
`menu_order` int(11) NOT NULL DEFAULT '0',
`post_type` varchar(20) NOT NULL DEFAULT 'post',
`post_mime_type` varchar(100) NOT NULL DEFAULT '',
`comment_count` bigint(20) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
KEY `post_name` (`post_name`),
KEY `type_status_date` (`post_type`,`post_status`,`post_date`,`ID`),
KEY `post_parent` (`post_parent`),
KEY `post_author` (`post_author`)
) ENGINE=MyISAM AUTO_INCREMENT=2743 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */; --
-- Dumping data for table `wp_posts`
--
--- les données viennent ensuite...
EasyPHP | Install a local WAMP server : PHP 5 VC9, Apache 2 VC9, MySQL 5, PhpMyAdmin, Xdebug and Modules on Windows XP/Vista/Seven sur PC http://www.easyphp.org/
Quelques stencils de Graffletopia utiles pour les “wireframes” de BDD, MySQL-schema.graffle.gstencil, aws_icons_database.gstencil, AWS Database.gstencil https://www.graffletopia.com/
By now, Bruno Flaven works as AI Coordinator. He has been a project manager in a wide variety of Internet business applications both in Mobile and in Desktop for 20 years now. You can find more information about his professional life on his personal website (www.flaven.fr) or his linkedin profile: https://www.linkedin.com/in/brunoflaven. He is currently working In France Media Monde (FMM) mostly on mobile applications (iOS and Android). He has also worked as P.O for a Backoffice project made with Symfony. He also made few trainings to facilitate the handling of the tools that he helps to make. View all posts by Bruno Flaven