关于 MySQL

MySQL 是最流行的开源数据库。

本文简明的讲解了 MySQL 如何下载安装到使用的整个过程。

MySQL 支持多种特性:

使用 C和 C++编写,并使用了多种编译器进行测试,保证了源代码的可移植性。

支持 AIX、FreeBSD、HP-UX、Linux、Mac OS、NovellNetware、OpenBSD、OS/2 Wrap、Solaris、Windows等多种操作系统。

为多种编程语言提供了 API。这些编程语言包括 C、C++、Python、Java、Perl、PHP、Eiffel、Ruby,.NET和 Tcl 等。支持多线程,充分利用 CPU 资源。

优化的 SQL查询算法,有效地提高查询速度。

既能够作为一个单独的应用程序应用在客户端服务器网络环境中,也能够作为一个库而嵌入到其他的软件中。

提供多语言支持,常见的编码如中文的 GB 2312、BIG5,日文的 Shift_JIS等都可以用作数据表名和数据列名。

提供 TCP/IP、ODBC 和 JDBC等多种数据库连接途径。

提供用于管理、检查、优化数据库操作的管理工具。

支持大型的数据库。可以处理拥有上千万条记录的大型数据库。

支持多种存储引擎。

MySQL 是开源的,所以你不需要支付额外的费用。

MySQL 使用标准的 SQL数据语言形式。

MySQL 对 PHP 有很好的支持,PHP是目前最流行的 Web 开发语言。

MySQL是可以定制的,采用了 GPL协议,你可以修改源码来开发自己的 MySQL 系统。

在线 DDL/更改功能,数据架构支持动态应用程序和开发人员灵活性(5.6[3] 新增)

复制全局事务标识,可支持自我修复式集群(5.6[3] 新增)

复制无崩溃从机,可提高可用性(5.6[3] 新增)

复制多线程从机,可提高性能(5.6[3] 新增)

下载、安装

本例用的是 MySQL Community Edition (GPL) 版本,开源免费。

版本号:MySQL Community Server 5.6.24

平台类型: Windows

安装方式,可以选择 MySQL Installer MSI 或者是 编译压缩包(形如 mysql-5.6.26-win32.zip 或 mysql-5.6.26-winx64.zip)。

下载完成后,解压到放到任意目录,本例为 C:\mysql 目录

设置环境变量

放到 Path 变量下增加 ,C:\mysql\bin

配置

复制安装目录下的 my-default.ini 并重命名为 my.ini ,修改为

[mysqld]

basedir=C:/mysql

datadir=D:/MysqlData/data

basedir 为 mysql 安装目录。datadir 为数据存放目录

安装服务

安装作为 Windows 服务。

MySQL 会随着 Windows 的启动和关闭而启动和关闭

mysqld –install

C:\Users\Administrator.USER-20150424OX>mysqld –install

Service successfully installed.

其他可选的有:设置为手动启动或者关闭服务

mysqld –install-manual

移除服务

mysqld –remove

启动、关闭服务

启动

NET START MySQL

C:\Users\Administrator.USER-20150424OX>NET START MySQL

MySQL 服务正在启动 .

MySQL 服务已经启动成功。

关闭

NET STOP MySQL

C:\Users\Administrator.USER-20150424OX>NET STOP MySQL

MySQL 服务正在停止.

MySQL 服务已成功停止。

测试安装是否成功

mysqlshow

C:\Users\Administrator.USER-20150424OX>mysqlshow

+--------------------+

| Databases |

+--------------------+

| information_schema |

| test |

+--------------------+

mysqlshow -u root mysql

C:\Users\Administrator.USER-20150424OX>mysqlshow -u root mysql

Database: mysql

+---------------------------+

| Tables |

+---------------------------+

| columns_priv |

| db |

| event |

| func |

| general_log |

| help_category |

| help_keyword |

| help_relation |

| help_topic |

| innodb_index_stats |

| innodb_table_stats |

| ndb_binlog_index |

| plugin |

| proc |

| procs_priv |

| proxies_priv |

| servers |

| slave_master_info |

| slave_relay_log_info |

| slave_worker_info |

| slow_log |

| tables_priv |

| time_zone |

| time_zone_leap_second |

| time_zone_name |

| time_zone_transition |

| time_zone_transition_type |

| user |

+---------------------------+

mysqladmin version status proc

C:\Users\Administrator.USER-20150424OX>mysqladmin version status proc

mysqladmin Ver 8.42 Distrib 5.6.24, for Win64 on x86_64

Copyright (c) 2000, 2015, 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.

Server version 5.6.24

Protocol version 10

Connection localhost via TCP/IP

TCP port 3306

Uptime: 9 min 12 sec

Threads: 1 Questions: 7 Slow queries: 0 Opens: 67 Flush tables: 1 Open tabl

es: 60 Queries per second avg: 0.012

Uptime: 552 Threads: 1 Questions: 8 Slow queries: 0 Opens: 67 Flush tables:

1 Open tables: 60 Queries per second avg: 0.014

mysqladmin: process list failed; error: ‘Access denied; you need (at least one o

f) the PROCESS privilege(s) for this operation‘

mysql test

C:\Users\Administrator.USER-20150424OX>mysql test

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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.

使用

列出所有的帮助命令

mysql –help

连接到服务器,其中 host 是服务器IP, user 是用户名

mysql -h host -u user -p

如果服务器在本地 ,

mysql -u user –p

提示输入密码,验证通过后,如下

C:\Users\Administrator.USER-20150424OX>mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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.

mysql>

断开与服务器的链接

QUIT

mysql> QUIT

Bye

查询(命令语句是不区分大小写)

mysql> SELECT VERSION(), CURRENT_DATE;

+-----------+--------------+

| VERSION() | CURRENT_DATE |

+-----------+--------------+

| 5.6.24 | 2015-05-10 |

+-----------+--------------+

1 row in set (0.01 sec)

列出所有数据库

mysql> SHOW DATABASES;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| test |

+--------------------+

4 rows in set (0.00 sec)

创建一个自己的数据库 menagerie

mysql> CREATE DATABASE menagerie;

Query OK, 1 row affected (0.03 sec)

给自己授予管理员权限

GRANT ALL ON menagerie.* TO ‘your_mysql_name‘@‘your_client_host‘;

访问数据库 menagerie

mysql> USE menagerie

Database changed

列出数据库表

mysql> SHOW TABLES;

Empty set (0.00 sec)

创建表 pet

mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),

-> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);

Query OK, 0 rows affected (0.43 sec)

查看 pet 表的详情

mysql> DESCRIBE pet;

+---------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------+-------------+------+-----+---------+-------+

| name | varchar(20) | YES | | NULL | |

| owner | varchar(20) | YES | | NULL | |

| species | varchar(20) | YES | | NULL | |

| sex | char(1) | YES | | NULL | |

| birth | date | YES | | NULL | |

| death | date | YES | | NULL | |

+---------+-------------+------+-----+---------+-------+

6 rows in set (0.01 sec)

插入数据

mysql> INSERT INTO pet

-> VALUES (‘Puffball‘,‘Diane‘,‘hamster‘,‘f‘,‘1999-03-30‘,NULL);

Query OK, 1 row affected (0.04 sec)

查询所有的数据

mysql> SELECT * FROM pet;

+----------+-------+---------+------+------------+-------+

| name | owner | species | sex | birth | death |

+----------+-------+---------+------+------------+-------+

| Puffball | Diane | hamster | f | 1999-03-30 | NULL |

+----------+-------+---------+------+------------+-------+

1 row in set (0.00 sec)

修改数据

mysql> UPDATE pet SET birth = ‘1989-08-31‘ WHERE name = ‘Puffball‘;

Query OK, 1 row affected (0.11 sec)

Rows matched: 1 Changed: 1 Warnings: 0

删除数据

mysql> DELETE FROM pet;

Query OK, 1 row affected (0.04 sec)

参考

原文:http://my.oschina.net/waylau/blog/413904

mysql用com_MySQL 使用教程相关推荐

  1. mysql数据库解压安装教程_MySQL数据库之windows 10下解压版MySql安装配置方法教程...

    本文主要向大家介绍了MySQL数据库之windows 10下解压版MySql安装配置方法教程 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助. windows 10 下安装解压版的 ...

  2. centos7 mysql workbench_centOS下mysql workbench安装配置教程

    本文为大家分享了mysql workbench安装配置教程,供大家参考,具体内容如下 step0:安装mysql 在按照workbench之前,先安装mysql.指令是 yum install mys ...

  3. Mysql数据库的安装教程

    Mysql数据库的安装教程 一.Mysql数据库介绍 二.Mysql数据库特性 1.Mysql现状 2.Mysql的几个特点 三.Mysql数据库中术语介绍 四.检查MySQL 是否安装 1.检测系统 ...

  4. centos6.5安装mysql8_Centos6.5在线安装mysql 8.0详细教程

    Centos6.5在线安装mysql 8.0的顺序如下,希望大家可以顺利进行安装. Mysql卸载从下往上顺序 ?[root@localhost /]# rpm -e --nodeps qt-MySQ ...

  5. wamp安装多版本php,WampServer下安装多个版本的PHP、mysql、apache图文教程

    WampServer下安装多个版本的PHP.mysql.apache图文教程今天,我在调试一套PHP程序的时候,该程序中使用的某些函数在低版本中无法使用,所以只能在搞个高版本的php. 作为Web开发 ...

  6. MySQL全文索引应用简明教程

    MySQL全文索引应用简明教程 本文从以下几个方面介绍下MySQL全文索引的基础知识: MySQL全文索引的几个注意事项 全文索引的语法 几种搜索类型的简介 几种搜索类型的实例 全文索引的几个注意事项 ...

  7. iis8.5 php mysql_Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程

    这篇文章主要介绍了Win2012 R2 IIS8.5+PHP(FastCGI)+MySQL运行环境搭建教程,需要的朋友可以参考下 准备篇 一.环境说明: 操作系统:Windows Server 201 ...

  8. MySQL 下载与配置教程(免安装版)

    MySQL 下载与配置教程(免安装版) 说明 步骤 此博客已不再维护,更新内容将更新在另一篇博客中,链接:https://blog.csdn.net/wangpaiblog/article/detai ...

  9. mysql数据库项目化教程郑小蓉_MySQL数据库项目化教程(高等职业教育“十三五”规划教材(软件技术专业))...

    <MySQL数据库项目化教程/高等职业教育十三五规划教材(软件技术专业)>是一本介绍MySQL数据库基础知识的入门教材,采用项目驱动方式循序渐进地介绍MySQL各个模块的知识.主要内容包括 ...

最新文章

  1. 小程序一次性上传多个本地图片,上拉加载照片以及图片加载延迟解决之道
  2. Codeforces Beta Round #9 (Div. 2 Only) C. Hexadecimal's Numbers dfs
  3. 2021年北京高校数学建模校际联赛题目_B
  4. 怪咖发明家,乔布斯给了他四亿,他没要,转身靠发明救了10亿人。
  5. python self 值自动改变,在python中对self的理解
  6. python exec_Python exec()
  7. winRar禁止弹窗广告方法
  8. (附源码)Springboot小型仪器公司生产管理系统 毕业设计 031853
  9. cad没有命令输入框_cad命令输入框没了(CAD 输入命令栏显示在绘图的屏幕上怎么设置)...
  10. 转载:使用pythonr脚本实现微信公众号音频批量下载
  11. Codeforces 868C - Qualification Rounds 思维
  12. 云计算主要包含哪些基本特征?
  13. 智慧校园管理系统,精细化+网格化
  14. 备案域名服务器DNS修改,未备案域名也可以用高防CDN加速
  15. mysql connector java5.1.30_mysql connector java下载
  16. Mac 修改命令行前缀显示
  17. 【JAVA学习】java中怎么遍历HashMap(Iterator迭代器遍历)
  18. MIT6.830-2022-lab4实验思路详细讲解
  19. 北大肖臻老师《区块链技术与应用》系列课程学习笔记[1]Bitcoin中用到的密码学原理和数据结构
  20. 【夏目鬼鬼分享】rabbitmq消息队列发送于接收

热门文章

  1. JAXB –不需要注释
  2. 使用ActiveMQ支持Spring Integration路由
  3. 分叉并加入Java 7 – JSR 166并发实用程序
  4. 使用ASM 4处理Java类文件–第二部分:Tree API
  5. Spring3 RESTful Web服务
  6. Linux 命令之 rpmbuild -- 用于创建 rpm 格式的二进制软件包和源码软件包
  7. php 表单 同步,Jquery点击按钮 异步和同步提交表单
  8. 名词解释多媒体计算机,多媒体-名词解释及填空
  9. 嵌入式linux应用程序实例,嵌入式Linux应用程序访问物理地址的实例
  10. 用于单片机的几种C语言算法