首先登陆官网。我们在这里选用的是社区版本的win64sql。版本号为5.7.13
在网站上,我们很容易就找教程和技术手册
http://dev.mysql.com/doc/refman/5.7/en/tutorial.html
当然你也可以
mysql –help来寻求帮助
安装完成后首先修改默认设置my_default.ini
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#myOwn
#使用端口
port = 3306
#设置字符集
default-character-set=utf8
#设置mysql数据库的数据的存放目录
datadir=D:\mysql-5.7.13-winx64\data
# 允许最大连接数
max_connections=200
#服务器端使用的字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
然后,安装服务
请手动切换到mysql的bin目录下
输入以下命令,(因为版本的原因,我们的命令可能不相同)
请保证所设置的data文件夹为空
mysqld –initialize
mysqld –install
net start mysqld
如果你不愿意每次都切换目录的话,可以将这个目录放在环境变量path下面。
下面介绍下一些常用操作:
连接和断开数据库
mysql -h host -u user -p
host在这里指代逆向登陆的计算机名。不过,如果我们只打算登陆本地计算机的数据库的话,不用加-h选项
使用QUIT命令可以断开数据库
初始的登录操作为
mysql -u root -p
密码为空
检查数据库基本设置
实际上对于mysql关键字大小写随意,但是我们更乐意统一大写
SHOW DATABASES;
显示已经配置的数据库
SELECT VERSION(), CURRENT_DATE;
显示当前版本和日期
SELECT USER();
查询表单
一个典型的查询语句如下图所示
mgsql>SELECT * FROM my_table WHERE name = ‘Smith’ AND age < 30;
注意,在sql语句中经常由于过于复杂,在一行写完实在容易得颈椎病,于是mgsql中有换行机制,此时,开始的mysql>提示符会产生变化。
mysql> Ready for new query
-> Waiting for next line of multiple-line query
'> Waiting for next line, waiting for completion of a string that began with a single quote (“'”)
"> Waiting for next line, waiting for completion of a string that began with a double quote (“"”)
`> Waiting for next line, waiting for completion of an identifier that began with a backtick (“`”)
/*> Waiting for next line, waiting for completion of a comment that began with /*
另外一些简单的操作请参见
在这里,我们先介绍如何让数据库支持远程操作
新建一个用户,让用户可以在任何地点访问数据库
然后对用户修改密码
如果连接不上,更改防火墙设置就好了。
另外一些简单的操作可以欣赏
http://www.cnblogs.com/mr-wid/archive/2013/05/09/3068229.html