Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1065887
  • 博文数量: 239
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 3618
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-12 13:17
文章分类

全部博文(239)

文章存档

2021年(1)

2016年(1)

2015年(30)

2014年(91)

2013年(116)

分类: WINDOWS

2014-02-10 19:23:33

1.连接至mysql
C:\mysql-advanced-5.6.15-winx64\bin>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.15-enterprise-commercial-advanced MySQL Enterprise Server -
Advanced Edition (Commercial)


Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.


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


2.创建数据库
mysql> create database hbhe;
Query OK, 1 row affected (0.01 sec)

3.连接至数据库
mysql> use hbhe;
Database changed


4.显示数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hbhe               |
| mysql              |
| performance_schema |
| sakila             |
| test               |
| world              |
+--------------------+
7 rows in set (0.01 sec)


5.删除数据库
mysql> drop database hbhe;
Query OK, 0 rows affected (0.01 sec)

6.创建数据库表
mysql> use hbhe;
Database changed
mysql> CREATE TABLE MYTABLE (name VARCHAR(20), sex CHAR(1));
Query OK, 0 rows affected (0.09 sec)

7.显示表结构
mysql> DESCRIBE MYTABLE;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| name  | varchar(20) | YES  |     | NULL    |       |
| sex   | char(1)     | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.01 sec)

8.在表中加入数据
mysql> insert into MYTABLE values("hbhe","M");
Query OK, 1 row affected (0.01 sec)

9.更新表
mysql> update MYTABLE set sex="f" where name = 'hbhe';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

10.清空表
mysql> delete from mytable;
Query OK, 1 row affected (0.02 sec)

11.删除表
mysql> drop table mytable;
Query OK, 0 rows affected (0.03 sec)

12.更改表名
mysql> rename table mytable to yourtable;
Query OK, 0 rows affected (0.03 sec)

13.导出hbhe库信息
C:\mysql-advanced-5.6.15-winx64\bin>mysqldump -u root -p hbhe >hbhe.sql
Enter password: ******
库信息如下
-- MySQL dump 10.13  Distrib 5.6.15, for Win64 (x86_64)
--
-- Host: localhost    Database: hbhe
-- ------------------------------------------------------
-- Server version 5.6.15-enterprise-commercial-advanced


/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


--
-- Table structure for table `yourtable`
--


DROP TABLE IF EXISTS `yourtable`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `yourtable` (
  `name` varchar(20) DEFAULT NULL,
  `sex` char(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;


--
-- Dumping data for table `yourtable`
--


LOCK TABLES `yourtable` WRITE;
/*!40000 ALTER TABLE `yourtable` DISABLE KEYS */;
/*!40000 ALTER TABLE `yourtable` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;


/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


-- Dump completed on 2014-02-10 19:14:11



14.导出一张表
C:\mysql-advanced-5.6.15-winx64\bin>mysqldump -u root -p hbhe yourtable > yourtable.sql
Enter password: ******

yourtable表中内容如下:
-- MySQL dump 10.13  Distrib 5.6.15, for Win64 (x86_64)
--
-- Host: localhost    Database: hbhe
-- ------------------------------------------------------
-- Server version 5.6.15-enterprise-commercial-advanced


/*!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 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


--
-- Table structure for table `yourtable`
--


DROP TABLE IF EXISTS `yourtable`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `yourtable` (
  `name` varchar(20) DEFAULT NULL,
  `sex` char(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;


--
-- Dumping data for table `yourtable`
--


LOCK TABLES `yourtable` WRITE;
/*!40000 ALTER TABLE `yourtable` DISABLE KEYS */;
INSERT INTO `yourtable` VALUES ('hbhe','M');
/*!40000 ALTER TABLE `yourtable` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;


/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;


-- Dump completed on 2014-02-10 19:21:33




阅读(3092) | 评论(0) | 转发(1) |
0

上一篇:RHEL6上安装was7

下一篇:linux uname命令

给主人留下些什么吧!~~