欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux mysql 数据库操作导入导出 数据表导出导入

程序员文章站 2024-03-21 10:08:28
...

测试、生产环境中,有时并不需要在本地安装一个mysql server服务,只需要安装一个登录mysql server 的mysql的客户端client

centos6系统上安装mysql-client的方式:
yum install mysql-clent mysql-devel -y

centos7的系统上安装mysql client的方式:
yum install -y mariadb.x86_64 mariadb-libs.x86_64

 

导库: mysqldump  -p 192.168.1.101 -uroot -p product_center > /home/zxz/product.sql

导表: mysqldump  -p 192.168.1.101 -uroot -p product_center product > /home/zxz/product.sql

导表结构:mysqldump  -p 192.168.1.101 -uroot -p -d product_center product > /home/zxz/product.sq

 

导出product_center.product表数据:

[[email protected] bin]# which mysql
/usr/bin/mysql
[[email protected] bin]# cd /usr/bin/
[[email protected] bin]# mysqldump  -p 192.168.1.101 -uroot -p product_center product > /home/zxz/product.sql

导出product_center.product表结构: mysqldump  -p 192.168.1.101 -uroot -p -d product_center product > /home/zxz/product.sql

 

导入:

source /home/cjf/product_date.sql

[[email protected] bin]# which mysql
/usr/bin/mysql
[[email protected] bin]# cd /usr/bin/
[[email protected] bin]# mysql -h 192.168.1.102 -ucjf -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 108
Server version: 5.7.20 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cjf                |
+--------------------+
2 rows in set (0.01 sec)

MySQL [(none)]> use cjf
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MySQL [cjf]> source /home/cjf/product.sql