图形界面安装MySQL5.6
关于图形界面的安装,网上相关相关资料比较多,此处省略安装过程。安装过程中选择安装路径、所需组件及root账号密码。
1、目前针对不同用户,MySQL提供了2个不同的版本:
MySQL Community Server:社区版,该版本完全免费,但是官方不提供技术支持。
MySQL Enterprise Server:企业版,它能够高性价比的为企业提供数据仓库应用,支持ACID事物处理,提供完整的提交、回滚、崩溃恢复和行级锁定功能。但是该版本需付费使用,官方提供电话及文档等技术支持。
2、MySQL服务器的类型
Developer Machine(开发机器):该选项代表典型个人用桌面工作站。假定机器上运行着多个桌面应用程序。将MySQL服务器配置成使用最少的系统资源。
Server Machine(服务器):该选项代表服务器,MySQL服务器可以同其它应用程序一起运行,例如FTP、email和web服务器。MySQL服务器配置成使用适当比例的系统资源。
Dedicated MySQL Server Machine(专用MySQL服务器):该选项代表只运行MySQL服务的服务器。假定运行没有运行其它应用程序。MySQL服务器配置成使用所有可用系统资源。
作为初学者,选择“Developer Machine”(开发者机器)已经足够了,这样占用系统的资源不会很多。在Enable TCP/IP Networking左边的复选框中可以启用或禁用TCP/IP网络,并配置用来连接MySQL服务器的端口号,默认情况启用TCP/IP网络,默认端口为3306。
3、安装完后windows服务管理中会默认添加一个服务MySQL56
启停命令为:net start/stop MySQL56
如果使用该命令启停时报错:检查服务器管理器的mysql服务的服务名是否正确,检查配置文件:
C:Program FilesMySQLMySQL Server 5.6my-default.ini,加上basedir和datadir:
# These are commonly set, remove the # and set as required.
basedir =C:Program FilesMySQLMySQL Server 5.6
datadir =C:Program FilesMySQLMySQL Server 5.6data ---相关日志也在这个目录下
# port = .....
# server_id = .....
配置文件:
C:ProgramDataMySQLMySQL Server 5.6my.ini --启动时用的是这个配置文件
C:Program FilesMySQLMySQL Server 5.6my-default.ini --这个配置文件是个模块,删除也不影响启动。
4、在环境变量PATH里加入MySQL安装路径的bin目录
C:Program FilesMySQLMySQL Server 5.6in;
安装完成。
------------
说明:如果下载的是非安装版的zip格式安装包,则解压后直接修改配置文件my-default.ini即可。
在mysql bin目录下,以管理员的权限执行mysqld -install命令,会在windows服务管理器里注册MySQL服务。mysqld -remove 卸载mysql服务
======================
MySQL数据库连接:
1、使用MySQL Command Line连接数据库
选择菜单:开始>所有程序>MySQL>MySQL Server 5.6>MySQL 5.6 Command Line Client
打开MySQL Command Line Client程序,输入root密码即可登录数据库。
Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 10
Server version: 5.6.23-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced
Edition (Commercial)
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>
2、使用MySQL命令登录数据库,MySQL命令语法:
mysql [-u username] [-h host] [-p[password]] [dbname]
C:UsersAdministrator>mysql -uroot -prusky
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 13
Server version: 5.6.23-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced
Edition (Commercial)
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>
3、C:UsersAdministrator>mysql -uroot -p
Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 15
Server version: 5.6.23-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced
Edition (Commercial)
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>
二、基本信息查询
1、查看数据库参数
mysql> show variables like 'version%';
+-------------------------+---------------------------------------------------------+
| Variable_name | Value |
+-------------------------+---------------------------------------------------------+
| version | 5.6.23-enterprise-commercial-advanced-log |
| version_comment | MySQL Enterprise Server - Advanced Edition (Commercial) |
| version_compile_machine | x86_64 |
| version_compile_os | Win64 |
+-------------------------+---------------------------------------------------------+
4 rows in set (0.00 sec)
或者:mysql> show variables; --查看全部参数
2、配置会话参数
mysql> show variables like '%sort_buffer_size%';
+-------------------------+----------+
| Variable_name | Value |
+-------------------------+----------+
| innodb_sort_buffer_size | 1048576 |
| myisam_sort_buffer_size | 69206016 |
| sort_buffer_size | 262144 |
+-------------------------+----------+
3 rows in set (0.00 sec)
mysql> set session sort_buffer_size= 262148;
Query OK, 0 rows affected (0.00 sec)
3、配置全局参数
mysql> set global sort_buffer_size=262160;
Query OK, 0 rows affected (0.00 sec)
mysql> show global variables like '%sort_buffer_size%';
+-------------------------+----------+
| Variable_name | Value |
+-------------------------+----------+
| innodb_sort_buffer_size | 1048576 |
| myisam_sort_buffer_size | 69206016 |
| sort_buffer_size | 262160 |
+-------------------------+----------+
3 rows in set (0.00 sec)
4、查看数据库字符集
mysql> show variables like 'character\_set\_%';
+--------------------------+--------+
| Variable_name | Value |
+--------------------------+--------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | utf8 |
| character_set_system | utf8 |
+--------------------------+--------+
7 rows in set (0.00 sec)
5、查看所有数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| world |
+--------------------+
5 rows in set (0.00 sec)
6、use连接到某一数据库,并查看该数据库中的表
mysql> use world
Database changed
mysql> show tables;
+-----------------+
| Tables_in_world |
+-----------------+
| city |
| country |
| countrylanguage |
+-----------------+
3 rows in set (0.00 sec)
7、查看当前连接的数据库
mysql> select database();
+------------+
| database() |
+------------+
| world |
+------------+
1 row in set (0.00 sec)
8、数据库的创建与删除
create database testdb;
drop database testdb;