一、在官网上下载相应的mysql安装包,本人下载的是:mysql-5.7.10-winx64 (Windows (x86, 64-bit), ZIP Archive)
附下载地址:http://dev.mysql.com/downloads/mysql/
二、将下载后的文件解压到指定目录(如:E:SunSSMmysql-5.7.10-winx64),并在该目录下新建一个my.ini文件基内容如下(注意目录要与你解压的对应)
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=E:SunSSMmysql-5.7.10-winx64
# 设置mysql数据库的数据的存放目录
#datadir=E:SunSSMmysql-5.7.10-winx64data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
三、进入cmd界面
1、安装mysql
C:UsersAdministrator>e:
E:>cd Sun
E:Sun>cd SSM
E:SunSSM>cd mysql-5.7.10-winx64
E:SunSSMmysql-5.7.10-winx64>cd bin
E:SunSSMmysql-5.7.10-winx64in>mysqld --install
2、初始化开生成data文件夹
C:UsersAdministrator>e:
E:>cd Sun
E:Sun>cd SSM
E:SunSSM>cd mysql-5.7.10-winx64
E:SunSSMmysql-5.7.10-winx64>cd bin
E:SunSSMmysql-5.7.10-winx64in>mysqld --initialize
3、启动服务(也可以在服务中去手动启动)
C:UsersAdministrator>e:
E:>cd Sun
E:Sun>cd SSM
E:SunSSM>cd mysql-5.7.10-winx64
E:SunSSMmysql-5.7.10-winx64>cd bin
E:SunSSMmysql-5.7.10-winx64in>net start mysql
4、查看默认密码及修改密码(在解压目录:E:SunSSMmysql-5.7.10-winx64data下有个计算机名.err的文件,我的计算机名是Sun )
4.1 Sun.err (其中有个临时密码:yCo2*#ZnQ2Ma)
2016-01-05T10:53:53.345887Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-05T10:53:57.985152Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-01-05T10:53:59.486238Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-05T10:53:59.868260Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a032b5c6-b39a-11e5-b224-f0761c00e1af.
2016-01-05T10:53:59.972266Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-01-05T10:53:59.992267Z 1 [Note] A temporary password is generated for root@localhost: yCo2*#ZnQ2Ma
4.2 修改密码
C:UsersAdministrator>e:
E:>cd Sun
E:Sun>cd SSM
E:SunSSM>cd mysql-5.7.10-winx64
E:SunSSMmysql-5.7.10-winx64>cd bin
E:SunSSMmysql-5.7.10-winx64in>mysql -u root -p
然后输入临时密码,输入正确后会有mysql>
再输入: set password for root@localhost = password('12345'); //注意分号不能少,将密码设置成12345