当前位置:网站首页>MySQL命令行导入导出数据
MySQL命令行导入导出数据
2022-06-10 22:40:00 【Li_XiaoJin】
在重构系统,原来系统使用的是 MySQL,现在需要换成 PostgreSQL,所以需要将数据迁移。目前的计划是将生产数据库的记录导出来,导入到测试环境的一个备份库,再用程序将数据转换导入到新的 PostgreSQL 数据库,所以涉及到生产数据库导出,由于生产数据库不能用 Navicat 等软件连接,所以只能用命令行导出,记录一下。
导出
这个步骤不需要登录数据库,直接使用 mysqldumpl 命令就可以进行导出。
导出整个库
mysqldump -u 用户名 -p 数据库名 > 导出的文件名
mysqldump -u root -p --databases db_name > test_db.sql
导出一张表
mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名
只导出数据库结构,不带数据
mysqldump -u 用户名 -p -d 数据库名 > 导出的文件名
-d : 只备份结构,不备份数据。也可以使用”–no-data”代替”-d”,效果一样。
实例:
如果出现 -bash: mysqldump: command not found 的报错,处理如下:
找到 MySQL 的安装路径,
find / -name mysql -print
在 /usr/bin 目录下建立 mysqldump 的软链接
这里我的安装路径是 /usr/local/mysql/bin/mysqldump ,
执行命令 ln -fs /usr/local/mysql/bin/mysqldump /usr/bin/
执行完就可以使用 mysqldump 命令了。
导入
- 进入MySQL:mysql -u 用户名 -p
- 新建一个数据库,或者进入你要导入数据的数据库
输入:mysql>create database 要创建的数据库名;
或输入:mysql>use 要使用的数据库名;
- 导入文件,使用 source 命令导入的文件
输入命令行:mysql>source /文件路径/文件名.sql;
今天是神舟十二号发射的日子,祝神舟十二号一切顺利!三位航天员平安凯旋!向中国航天致敬!
英雄出征,穿云破日!
End.
Copyright: 采用 知识共享署名4.0 国际许可协议进行许可 Links:https://lixj.fun/archives/mysql命令行导出数据
边栏推荐
- Dark horse headlines - Tencent's salary system reform has caused controversy; Intel expanded the recruitment of female engineers nationwide; Black horse is 100% employed really
- Kubernetes 基本介绍及核心组件
- Simple impedance matching circuit and formula
- csdn每日一练——有序表的折半查找
- 怎么生成自动参考文献(简单 有图)
- LabVIEW确定控件在显示器坐标系中的位置
- LabVIEW pictures look bright or dark after being cast from 16 bits to 8 bits
- [new version] new pseudo personal homepage v2.0- starze V Club
- 宁愿“大小周”、每天只写 200 行代码、月薪 8k-17k 人群再涨
- Example analysis of SQL query optimization principle
猜你喜欢

LabVIEW打开其他EXE程序

Unity 脚本无法显示C#源码的中文注释 或者VS创建的脚本没有C#源码的注释

Chapter 6 - branch and bound method

LabVIEW pictures look bright or dark after being cast from 16 bits to 8 bits

Data and information resource sharing platform (V)
![[paper sharing] pata: fuzzing with path aware Taint Analysis](/img/f6/627344c5da588afcf70302ef29d134.png)
[paper sharing] pata: fuzzing with path aware Taint Analysis

LabVIEW错误“内存已满 - 应用程序停止在节点”

MySQL table mechanism

LabVIEW open other exe programs

Self made app connected to onenet --- realize data monitoring and distribution control (mqtt)
随机推荐
自制APP连接OneNET---实现数据监控和下发控制(MQTT)
LabVIEW中NI MAX中缺少串口
上海网上开户是安全的吗?
OpenVP*整合ldap認證
LabVIEW图片在从16位强制转换为8位后看起来要亮或暗
The data file insurance CSV contains 1338 observations, that is, the registered beneficiaries of the insurance plan and the characteristics that represent the characteristics of patients and the total
Solutions to the error reported by executing Oracle SQL statement [ora-00904: "createtime": invalid identifier] and [ora-00913: too many values]
How to measure the refresh rate of oscilloscope
LabVIEW获取IMAQ Get Last Event坐标
Is it safe to open an account online in Shanghai?
Common settings for vs
Self made app connected to onenet --- realize data monitoring and distribution control (mqtt)
Openvp* integrated LDAP authentication
LabVIEW或MAX下的VISA测试面板中串口无法工作
LabVIEW锁相环(PLL)
Interview questions - written examination
Chapter 6 - branch and bound method
Serial port missing in Ni Max in LabVIEW
Data and information resource sharing platform (6)
Redis list list common commands