Import MySQL Dumpfile, SQL Datafile Into My Database
How can I import a MySQL dumpfile into my database? I'm using CentOS Linux 5 server. My old hosting provider gave me a data.sql file and I do have access to my Unix / Linux server via ssh. So How do I restore my data using command line over the ssh session?
You can easily restore or import MySQL data with the mysql command itself. First you need to login to your system using ssh or putty client.
Step #1: Upload File To MySQL Server
You can upload data.sql file using the sftp or scp command, enter: $ scp data.sql vivek@example.cyberciti.biz:/home/vivek
The data.sql file will be uploaded to /home/vivek directory. Avoid using /tmp or Apache document directory such as /var/www/html as anyone can see your data on the remote server.
Step #2: Login To Remote Server
Type the following command at the shell prompt: $ ssh loginname@example.cyberciti.biz
Replace example.cyberciti.biz with actual server name or an IP address.
Step#3: Import Datafile
Type the following command to import sql data file: $ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql
In this example, import 'data.sql' file into 'blog' database using vivek as username: $ mysql -u vivek -p -h localhost blog < data.sql
If you have a dedicated database server, replace localhost hostname with with actual server name or IP address as follows: $ mysql -u username -p -h 202.54.1.10 databasename < data.sql
OR use hostname such as mysql.cyberciti.biz $ mysql -u username -p -h mysql.cyberciti.biz database-name < data.sql
If you do not know the database name or database name is included in sql dump you can try out something as follows: $ mysql -u username -p -h 202.54.1.10 < data.sql
A Note About Creating A New Database and Importing Data
In this example create a mysql database called foo and import data from bar.sql.gz as follows:
mysql -u root -p -h localhost
Sample outputs:
mysql> create database foo;
mysql> exit;
Import bar.sql.gz:
gunzip bar.sql.gz
ls -l
mysql -u root -p -h localhost foo <bar.sql
You can also create a username and password for foo database using the following syntax:
mysql -u root -p -h localhost
Sample outputs:
mysql> GRANT ALL ON foo.* TO NEW-USERNAME-HERE@localhost IDENTIFIED BY 'YOUR-PASSWORD-HERE';
### allow access from 192.168.1.5 too ##
mysql> GRANT ALL ON foo.* TO NEW-USERNAME-HERE@192.168.1.5 IDENTIFIED BY 'YOUR-PASSWORD-HERE';
mysql> quit;
Page last updated at 4:37 PM, January 6, 2012.
Import MySQL Dumpfile, SQL Datafile Into My Database的更多相关文章
- Mysql错误:Ignoring query to other database解决方法
Mysql错误:Ignoring query to other database解决方法 今天登陆mysql show databases出现Ignoring query to other datab ...
- MySQL:MySQL和SQL Server的区别
导读:接下来的网上商城的项目,需要用到MySQL数据库了.这个对于我来说,是一个新接触的东西,按照惯例,在刚开始学习一个东西的时候,先从宏观上去了解它.本篇博客,先介绍SQL Server的基本内容, ...
- mysql之sql语句导入与导出讲解
导出SQL:mysqldump -u root -p 数据库名 [表名1 表名2] > 输出地址其中表名可选 本机测试实例:
- 使用 Oracle GoldenGate 在 Microsoft SQL Server 和 Oracle Database 之间复制事务
使用 Oracle GoldenGate 在 Microsoft SQL Server 和 Oracle Database 之间复制事务 作者:Nikolay Manchev 分步构建一个跨这些平台的 ...
- mysql 运行sql脚本文件
#只运行,不导出 mysql> source /home/user/to_run.sql; #导出 $ mysql -h host -u user -ppassword database < ...
- MySQL导入sql 文件的5大步骤
http://database.51cto.com/art/201005/200739.htm 以下的文章主要介绍的是MySQL导入sql 文件,即MySQL数据库导入导出sql 文件的实际操作步骤, ...
- MySQL进口.sql文件和常用命令
MySQL进口.sql文件和常用命令 在MySQL Qurey Brower中直接导入*.sql脚本,是不能一次运行多条sql命令的.在mysql中运行sql文件的命令: mysql> so ...
- sql点滴41—mysql常见sql语法
原文:sql点滴41-mysql常见sql语法 ALTER TABLE:添加,修改,删除表的列,约束等表的定义. 查看列:desc 表名; 修改表名:alter table t_book rename ...
- mysql中SQL执行过程详解与用于预处理语句的SQL语法
mysql中SQL执行过程详解 客户端发送一条查询给服务器: 服务器先检查查询缓存,如果命中了缓存,则立刻返回存储在缓存中的结果.否则进入下一阶段. 服务器段进行SQL解析.预处理,在优化器生成对应的 ...
随机推荐
- protobuf NET使用
首先,开源项目地址为: protobuf NET的GITHUB地址 下载下来后,打开项目,找到目录:Core/protobuf-net,生成一下,然后就可以在bin里得到protobuf-net.dl ...
- css权重计算
第一等:代表内联样式,如: style=””,权值为1000. 第二等:代表ID选择器,如:#content,权值为100. 第三等:代表类,伪类和属性选择器,如.content,权值为1 ...
- theano安装
theano安装有两类方法,一种是自己一步步安装,还有一种是借助其他软件安装.我是安装到一半发现第二种方法的...........所以就用的第一种麻烦的办法装的,但是过程也是一种学习. 电脑:win7 ...
- Hadoop配置文件-hdfs-site.xml
name value Description dfs.default.chunk.view.size 32768 namenode的http访问页面中针对每个文件的内容显示大小,通常无需设置. ...
- python 2.6升级到2.7
CentOS 6.5上安装的python版本是2.6.6,不能满足我运行软件的要求,所以对python进行升级. 原以为这也就是安装个软件的事儿,在我求稳搜索一下了之后发现,也并不是那么单纯简单. 下 ...
- Lowest Bit(hdoj1196)
Lowest Bit Problem Description Given an positive integer A (1 <= A <= 100), output the lowest ...
- QString转LPCWSTR
QFileInfo info("./records.db"); std::string str = info.absoluteFilePath().toStdString(); / ...
- Node.js HTTP 使用详解
对于初学者有没有发觉在查看Node.js官方API的时候非常简单,只有几个洋文描述两下子,没了,我第一次一口气看完所以API后,对于第一个示例都有些懵,特别是参数里的request和response, ...
- 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'tb_MyInvoices' 中的标识列插入显式值
默认情况下,IDENTITY_INSER就是off 这种情况下,你写insert 语句时,identity栏位,不要写值,系统会自动帮你写入. 举例说明: ,),dt datetime,pay int ...
- Nginx学习之三-ngx_http_request_t结构体
ngx_http_request_s是nginx中非常重要的一个结构体,贯穿于htpp请求处理的整个过程中. 下面解释了ngx_http_request_s结构体中与HTTP框架相关的重要的成员变量. ...
