1、 MySQL安装文件分为两种,一种是msi格式的,一种是zip格式的。如果是msi格式的可以直接点击安装,按照它给出的安装提示进行安装(相信大家的英文可以看懂英文提示),一般MySQL将会安装在C:\Program Files (x86)\MySQL\MySQL Server 5.6 该目录中;zip格式是自己解压,解压缩之后其实MySQL就可以使用了,但是要进行配置,这里本人放在了E:\Database\mysql中。
2、解压之后可以我将mysql5.6.28文件夹改为mysql,所以就是上面的E:\Database\mysql。
这里面我已将my-default.ini改名为my.ini,同时设置了字符集为utf-8,下面是我的配置文件
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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 = E:\Database\mysql
datadir = E:\Database\mysql\data
port = 3306
# server_id = .....
character_set_server = utf8
# 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
[client]
port = 3306
default-character-set = utf8
这里basedir和datadir为必选项,设置客户端和服务端字符集为utf-8,注意配置里面是utf8,没有短横
3、配置环境变量
我的电脑->属性->高级->环境变量
选择PATH,在其之前添加: E:\Database\mysql\bin; 记住别漏掉英文分号
PATH=E:\Database\mysql\bin;C:\Windows\..... (注意是追加,不是覆盖)
如图,本系统是win10
4、以管理员身份运行cmd(一定要用管理员身份运行,不然权限不够)
输入mysqld -install(如果不用管理员身份运行,将会因为权限不够而出现错误:Install/Remove of the Service Denied!)
安装成功
输入 net start mysql 服务启动成功
服务启动成功之后,就可以登录了,如图,输入mysql -u root -p(第一次登录没有密码,直接按回车过),登录成功!
流程如图所示:
5、下面查看下字符集配置有没有生效
输入 show variables like 'character%'; 进行查看,截图发现字符集已经修改好
6、下面我们对管理员密码进行修改
在用root 进入mysql后
mysql>set password =password('123');
mysql>flush privileges;
输入 exit; 断开数据库
我们试试能不能以刚设置的密码登入
输入 mysql -u root -p,提示我们输入密码,登入成功,截图如下
ps:如果发生 net start mysql 启动不了数据库(报系统错误 1067),则可以不需要新建my.ini,直接修改 my-default.ini即可