MySql 利用mysql&mysqldum导入导出数据
MySql 利用mysql&mysqldum导入导出数据
by:授客 QQ:1033553122
测试环境
Linux下测试,数据库MySql
工具
mysqldump,该命令位于mysql/bin/目录中:..../mysql/bin/mysqldump
步骤
1.cd 命令进入到mysqldump所在目录下。
首先得知道mysql命令或mysqldump命令的完整路径,可以使用find命令查找
如:查找mysqldump命令的完整路径,这里/usr/local/mysql是MySql数据库的安装路径
find / -name mysql -print
cd /usr/local/mysql/bin
2.导出指定数据库中的所有数据,把导出数据命名为hdlogsys.sql,存放与/usr目录下
/usr/local/mysql/bin# mysqldump -u root -p hdlogsys > /usr/hdlogsys.sql
-bash: mysqldump: command not found
解决办法:
1)首先考虑系统环境变量。
2)在环境变量ok的情况下,进行如下操作。
把mysqldump的路径如:/usr/local/mysql/bin/mysqldump,映射一个链接到/usr/bin目录下,相当于建立一个链接文件,如下
/usr/local/mysql/bin# ln -s /usr/local/mysql/bin/mysqldump usr/bin/mysqldump
注意:每次退出后再次使用就又要重新运行该命令
说明:
有时候安装好MySQL程序的时候,直接输入命令mysql或mysqldump会发现提示命令不存在,这是由于系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,当然会找不到命令
建立映射链接后,进入映射目录如:/usr/bin或者命令所在实际目录如:/usr/local/mysql/bin/mysqldump
键入上述的mysqldump命令,可以导出数据
4.cd 命令进入到mysqldump所在目录下。
cd /usr/local/mysql/bin
5.把导出的数据导入到指定数据库
【对于mysql命令,如果遇到上述问题,采与上述相同的解决方式。】
builder:/usr/local/mysql/bin# mysql -u root -p
Enter password:
(输入数据库访问密码)
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 39617
Server version: 5.5.23-MariaDB-log Source distribution
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>use heidunlog
(这里输use 要导入数据的数据库名)
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
MariaDB [heidunlog]>source /usr/heidunlog.sql
到这里如果要切换数据库名,则继续输入use语句
或者如下,直接指定数据库名
builder:/usr/local/mysql/bin# mysql -u root -p hdlogsys
Enter password:
(输入数据库访问密码)
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2104
Server version: 5.5.27-MariaDB-log Source distribution
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [hdlogsys]>source /usr/heidunlog.sql
MySql 利用mysql&mysqldum导入导出数据的更多相关文章
- mysql source、mysqldump 导入导出数据(转)
		解决了mysql gbk编码的导入导出问题,感谢作者. 一.导入数据 1.确定 数据库默认编码,比如编码 为gbk,将读入途径编码同样设为gbk,命令为: set names gb ... 
- 利用sqoop将hive数据导入导出数据到mysql
		一.导入导出数据库常用命令语句 1)列出mysql数据库中的所有数据库命令 # sqoop list-databases --connect jdbc:mysql://localhost:3306 ... 
- mysql导入导出数据中文乱码解决方法小结
		linux系统中 linux默认的是utf8编码,而windows是gbk编码,所以会出现上面的乱码问题. 解决mysql导入导出数据乱码问题 首先要做的是要确定你导出数据的编码格式,使用mysqld ... 
- 解决mysql导入导出数据乱码问题
		最近在linux上面用mysqldump导出数据,放在windows系统中导入就会出现中文乱码,然后就会导致出现: Unknown MySQL server host和Can't connect to ... 
- [转]mysql导入导出数据中文乱码解决方法小结
		本文章总结了mysql导入导出数据中文乱码解决方法,出现中文乱码一般情况是导入导入时编码的设置问题,我们只要把编码调整一致即可解决此方法,下面是搜索到的一些方法总结,方便需要的朋友. linux系统中 ... 
- Mysql & Hive 导入导出数据
		---王燕行转列sql select split(concat_ws(',',collect_set(cast(smzq as string))),',')[1] ,split(concat_ws(' ... 
- linux mysql 数据库操作导入导出 数据表导出导入
		linux mysql 数据库操作导入导出 数据表导出导入 1,数据库导入 mysql -uroot -p show databases; create database newdb; use 数据库 ... 
- 使用VUE+SpringBoot+EasyExcel 整合导入导出数据
		使用VUE+SpringBoot+EasyExcel 整合导入导出数据 创建一个普通的maven项目即可 项目目录结构 1 前端 存放在resources/static 下 index.html &l ... 
- CRL快速开发框架系列教程九(导入/导出数据)
		本系列目录 CRL快速开发框架系列教程一(Code First数据表不需再关心) CRL快速开发框架系列教程二(基于Lambda表达式查询) CRL快速开发框架系列教程三(更新数据) CRL快速开发框 ... 
随机推荐
- WebForm - 文本框回车事件
			document.getElementById("Pwd").onkeyup = function (e) { ) { fun_Login(); } }; 
- MapReduce中的partitioner
			1.日志源文件: 1363157985066 13726230503 00-FD-07-A4-72-B8:CMCC 120.196.100.82 i02.c.aliimg.com 24 27 2481 ... 
- Mac 下配置 Python 开发环境
			➜ ~ sudo brew install python3 ==> Downloading https://www.python.org/ftp/python/3.5.1/Python-3.5. ... 
- Kafka消费异常处理
			org.apache.kafka.clients.consumer.CommitFailedException: Commit cannot be completed since the group ... 
- c# winform as3相互调用
			C#主要代码: 首先要添加COM组件-Shockwave Flash Object //接收flash发送过来的信息 private void axShockwaveFlash1_Fla ... 
- 安装flutter和dart总结
			1 manjaro从软件仓库安装就行,但是也可以下载安装包.然后添加到Path目录 我是安装dart从软件仓库, flutter下载压缩包添加到path 1.1 需要将android sdk , ex ... 
- java多线程下的所的概念
			锁和synchronized关键字 为了同步多线程,Java语言使用监视器(monitors),一种高级的机制来限定某一 时刻只有一个线程执行一段受监视器保护的代码.监视器的行为是通过锁来实现 ... 
- docker网络之overlay
			使用docker network的好处是:在同一个网络上的容器之间可以相互通信,而无需使用expose端口特性 本文使用docker-swarm进行overlay网络的分析.使用2个vmware模拟2 ... 
- mycat中间件--linux安装mycat1.6版本
			一.mycat安装前准备1.mycat下载地址,点击此处进行下载2.环境要求如下: mycat使用Java开发,因为用到了JDK 7的部分功能,所以在使用前请确保安装了JDK 7.0,并设置了正确的J ... 
- 【IT笔试面试题整理】丑数
			[试题描述]我们把只包含因子2.3和5的数称作丑数.求按从到大的顺序的第1500个丑数.例如6,8是丑数,而14不是,因为它包含因子7.习惯上把1当作第一个丑数. 根据丑数的定义,丑数应该是另一个丑数 ... 
