没有合适的资源?快使用搜索试试~ 我知道了~
mysql命令行下导出,导入
资源推荐
资源详情
资源评论
数据的备份显得日益重要,下面是mysql常用的数据导入导出命令。
1.导出整个数据库
格式:mysqldump -u 用户名 -p 数据库名 > 导出的文件名
举例:
C:\Documents and Settings\Owner>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.7-beta-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use testdb
Database changed
mysql> select * from user;
+--------+----------+----------+---------------+
| userid | username | password | email |
+--------+----------+----------+---------------+
| 1 | aaa | aaa | aaaa |
| 2 | bbb | bbbb | bbbb@sina.com|
+--------+----------+----------+---------------+
2 rows in set (0.00 sec)
mysql> select * from user1;
+--------+----------+----------+---------------+
| userid | username | password | email |
+--------+----------+----------+---------------+
| 1 | cccc | cccc | cccc |
| 2 | cccc | cccc | cccc@sina.com|
+--------+----------+----------+---------------+
2 rows in set (0.00 sec)
1.导出整个数据库
格式:mysqldump -u 用户名 -p 数据库名 > 导出的文件名
举例:
C:\Documents and Settings\Owner>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.7-beta-nt
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use testdb
Database changed
mysql> select * from user;
+--------+----------+----------+---------------+
| userid | username | password | email |
+--------+----------+----------+---------------+
| 1 | aaa | aaa | aaaa |
| 2 | bbb | bbbb | bbbb@sina.com|
+--------+----------+----------+---------------+
2 rows in set (0.00 sec)
mysql> select * from user1;
+--------+----------+----------+---------------+
| userid | username | password | email |
+--------+----------+----------+---------------+
| 1 | cccc | cccc | cccc |
| 2 | cccc | cccc | cccc@sina.com|
+--------+----------+----------+---------------+
2 rows in set (0.00 sec)
在mysql的bin目录里面执行如下命令
C:\MySQL\MySQL Server 5.0\bin>mysqldump -u root -pnetcomm CTILOGUSER > ctiloguser.sql
Enter password:
C:\MySQL\MySQL Server 5.0\bin>
testdb.sql内容如下:
-- MySQL dump 10.10
--
-- Host: localhost Database: testdb
-- ------------------------------------------------------
-- Server version 5.0.7-beta-nt
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO__ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`userid` int(11) NOT NULL,
C:\MySQL\MySQL Server 5.0\bin>mysqldump -u root -pnetcomm CTILOGUSER > ctiloguser.sql
Enter password:
C:\MySQL\MySQL Server 5.0\bin>
testdb.sql内容如下:
-- MySQL dump 10.10
--
-- Host: localhost Database: testdb
-- ------------------------------------------------------
-- Server version 5.0.7-beta-nt
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO__ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `user`
--
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`userid` int(11) NOT NULL,
剩余10页未读,继续阅读
资源评论
1795800927
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功