Home  >  Article  >  System Tutorial  >  Centos7.3 Mariadb database export and import commands

Centos7.3 Mariadb database export and import commands

王林
王林Original
2024-07-21 10:20:58399browse

Centos7.3 Mariadb 数据库导出、导入命令

There are many solutions for exporting mariadb database, generally using phpmyadmin or Navicat for MySQL, etc. I will demonstrate the commonly used command line mode.

They are; -u user, -p password, database name, > export path. Ending with .sql.

/usr/local/mysql/bin/mysqldump -uroot -p renwole > /home/renwole.sql

Enter the user password after pressing Enter. The export is successful and the file is under home.

Note: If you only export the table structure, add -d after -p.

There are 2 solutions for importing database.

Option 1
MariaDB [(none)]> create database renwole; //建立空数据库名
MariaDB [(none)]> use renwole; //选择数据库
MariaDB [(none)]> set names utf8; //设置数据库导入编码
MariaDB [(none)]> source /home/renwole.sql; //导入数据(注意sql文件的路径)
Option 2
# mysql -uroot -p renwole 
<p>It is recommended to use the second method to import, which is simple and fast, does not require setting the import encoding, and is less error-prone. The above solution is also applicable to any version of mysql&mariadb</p>

The above is the detailed content of Centos7.3 Mariadb database export and import commands. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn