modifié : public/base-de-donnees/index.html modifié : public/base.css modifié : public/index.html modifié : public/intro.css modifié : sass/color.scss modifié : static/js/menu.js modifié : templates/partials/menu.html
109 lines
6.0 KiB
HTML
109 lines
6.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<link rel="stylesheet" href="/base.css" type="text/css">
|
|
<title> kitoy.me </title>
|
|
|
|
|
|
<title> kitoy.me </title>
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<div class="title">
|
|
<h1 style="text-align:center;"> kitoy.me </h1>
|
|
</div>
|
|
|
|
<div class="menugauche">
|
|
|
|
<div class="toggle" id="toggle" onclick="menu-expand()">
|
|
<h2 id="plus"> Menu </h2>
|
|
</div>
|
|
|
|
<div class="menu" id="menu">
|
|
<a href="https://kitoy.me">
|
|
<img src="/img/Blog-icon.svg" alt="Le blog" />
|
|
<p> Le blog </p>
|
|
</a>
|
|
|
|
<a href="https://losprimos.eu">
|
|
<img src="/img/music.svg" alt="Le blog" />
|
|
<p> Azul </p>
|
|
</a>
|
|
|
|
<a href="https://kitoy.me/rss.xml">
|
|
<img src="/img/resese.svg" alt="Suivez le blog par RSS" />
|
|
<p> RSS </p>
|
|
</a>
|
|
|
|
<a href="https://kitoy.me/contact/">
|
|
<img src="/img/mail.svg" alt="Contact" />
|
|
<p> Me contacter </p>
|
|
</a>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="articles">
|
|
|
|
<h1> Sauvegarder sa BDD et la restaurer </h1>
|
|
<h2 class="description">
|
|
Exporter/Importer une base de données avec mariadb 😄
|
|
</h2>
|
|
<hr />
|
|
|
|
<h3 id="d-abord-l-export">D'abord l'export:</h3>
|
|
<p>L'outil s'appelle mysqldump il est installé avec mariadb-server.</p>
|
|
<p>Donc on peut d'abord lister les base données pour être sûr de celle
|
|
que l'on veut exporter ? </p>
|
|
<pre style="background-color:#272822;">
|
|
<span style="color:#f8f8f2;">$ mysql</span><span style="font-style:italic;color:#fd971f;"> -u</span><span style="color:#f8f8f2;"> root</span><span style="font-style:italic;color:#fd971f;"> -p
|
|
</span><span style="color:#f8f8f2;">MariaDB </span><span style="color:#f92672;">[</span><span style="color:#f8f8f2;">(none)</span><span style="color:#f92672;">]></span><span style="color:#f8f8f2;"> SHOW DATABASES</span><span style="color:#f92672;">;
|
|
</span><span style="color:#f8f8f2;">+--------------------+
|
|
</span><span style="color:#f92672;">| </span><span style="color:#f8f8f2;">Database </span><span style="color:#f92672;">|
|
|
</span><span style="color:#f8f8f2;">+--------------------+
|
|
</span><span style="color:#f92672;">| </span><span style="color:#f8f8f2;">test1 </span><span style="color:#f92672;">|
|
|
| </span><span style="color:#f8f8f2;">information_schema </span><span style="color:#f92672;">|
|
|
| </span><span style="color:#f8f8f2;">mysql </span><span style="color:#f92672;">|
|
|
| </span><span style="color:#f8f8f2;">nextcloud </span><span style="color:#f92672;">|
|
|
| </span><span style="color:#f8f8f2;">performance_schema </span><span style="color:#f92672;">|
|
|
| </span><span style="color:#f8f8f2;">test </span><span style="color:#f92672;">|
|
|
</span><span style="color:#f8f8f2;">+--------------------+
|
|
|
|
</span></pre>
|
|
<p>Si par exemple on veut exporter la base nextcloud on tapera ceci
|
|
dans notre shell:</p>
|
|
<pre style="background-color:#272822;">
|
|
<span style="color:#f8f8f2;">$ mysqldump</span><span style="font-style:italic;color:#fd971f;"> -u</span><span style="color:#f8f8f2;"> root</span><span style="font-style:italic;color:#fd971f;"> -p</span><span style="color:#f8f8f2;"> nextcloud </span><span style="color:#f92672;">></span><span style="color:#f8f8f2;"> nextcloud_export.sql
|
|
</span></pre><h3 id="importer-sa-base-de-donnees">Importer sa base de données</h3>
|
|
<p>Pour importer notre fichier on va devoir créer la base et l'utilisateur qui aura
|
|
les droits sur la base. </p>
|
|
<pre style="background-color:#272822;">
|
|
<span style="color:#f8f8f2;">$ mysql</span><span style="font-style:italic;color:#fd971f;"> -u</span><span style="color:#f8f8f2;"> root</span><span style="font-style:italic;color:#fd971f;"> -p
|
|
</span><span style="color:#f8f8f2;">MariaDB </span><span style="color:#f92672;">[</span><span style="color:#f8f8f2;">(none)</span><span style="color:#f92672;">]></span><span style="color:#f8f8f2;"> CREATE DATABASE nextcloud</span><span style="color:#f92672;">;
|
|
</span><span style="color:#f8f8f2;">MariaDB </span><span style="color:#f92672;">[</span><span style="color:#f8f8f2;">(none)</span><span style="color:#f92672;">]></span><span style="color:#f8f8f2;"> CREATE USER nextbase IDENTIFIED BY </span><span style="color:#e6db74;">'example'</span><span style="color:#f92672;">;
|
|
</span><span style="color:#f8f8f2;">MariaDB </span><span style="color:#f92672;">[</span><span style="color:#f8f8f2;">(none)</span><span style="color:#f92672;">]></span><span style="color:#f8f8f2;"> GRANT ALL PRIVILEGES ON nextcloud.</span><span style="color:#f92672;">*</span><span style="color:#f8f8f2;"> TO nextbase</span><span style="color:#f92672;">;
|
|
</span><span style="color:#f8f8f2;">MariaDB </span><span style="color:#f92672;">[</span><span style="color:#f8f8f2;">(none)</span><span style="color:#f92672;">]></span><span style="color:#f8f8f2;"> FLUSH PRIVILEGES</span><span style="color:#f92672;">;
|
|
</span><span style="color:#f8f8f2;">MariaDB </span><span style="color:#f92672;">[</span><span style="color:#f8f8f2;">(none)</span><span style="color:#f92672;">]></span><span style="color:#f8f8f2;"> exit</span><span style="color:#f92672;">;
|
|
</span></pre>
|
|
<p>Si tout se passe bien normalement à la fin de chaque commande mysql
|
|
vous verrez un message Query OK ... , c'est que c'est bon :).</p>
|
|
<p>Maintenant on va pouvoir importer notre fichiers comme ceci : </p>
|
|
<pre style="background-color:#272822;">
|
|
<span style="color:#f8f8f2;">$ mysql</span><span style="font-style:italic;color:#fd971f;"> -u</span><span style="color:#f8f8f2;"> nextbase</span><span style="font-style:italic;color:#fd971f;"> -p</span><span style="color:#f8f8f2;"> nextcloud </span><span style="color:#f92672;"><</span><span style="color:#f8f8f2;"> nextcloud_export.sql
|
|
</span></pre>
|
|
<p>Si vous n'avez aucun message d'erreur, c'est fini ! </p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<footer><span class="copyleft">©</span> kitoy.me <br/> Site généré avec <a href="https://getzola.org/"> Zola </a> </footer>
|
|
|
|
<script src="https://kitoy.me/js/menu.js" ></script>
|
|
</body>
|
|
|
|
</html>
|