环境:win10 64位
mysql版本:mysql-5.7.9-winx64.zip (http://dev.mysql.com/downloads/mysql/)
首先声明一下,5.7.9这个版本的配置方式跟之前的免安装版配置不一样。(.msi安装版和其他版本的可以忽略该方法)
步骤:
1,在官网上下载了mysql-5.7.9-winx64.zip 这个文件之后, 解压到指定目录:F:\Java\mysql\mysql-5.7.9-winx64
2,在F:\java\mysql\mysql-5.7.9-winx64 目录创建data文件夹
3,将my.default.ini改名为my.ini放到bin目录,并且在my.ini目录加入如下代码:
basedir = F:\java\mysql\mysql-5.7.9-winx64
datadir = F:\java\mysql\mysql-5.7.9-winx64\data
port = 3306
4,配置环境变量,path=F:\java\mysql\mysql-5.7.9-winx64\bin
5,以管理员权限打开命令行,进入到F:\java\mysql\mysql-5.7.9-winx64\bin目录,
执行: mysqld –initialize –user=mysql –console
6,先执行以上命令, 会生成库. 注意有个临时密码, 要记下来.
F:\java\mysql\mysql-5.7.9\bin>mysqld --initialize --user=mysql --console
2015-11-03T02:12:10.856918Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-03T02:12:10.856918Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2015-11-03T02:12:10.856918Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2015-11-03T02:12:14.162565Z 0 [Warning] InnoDB: New log files created, LSN=45790
2015-11-03T02:12:14.884331Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-11-03T02:12:15.123784Z 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: 4d177d5b-81d0-11e5-bb66-c454443dc023.
2015-11-03T02:12:15.176861Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2015-11-03T02:12:15.189872Z 1 [Note] A temporary password is generated for root@localhost: v2toK7w,TJ_<
7,如本次执行的临时密码是:v2toK7w,TJ_<
8, 执行安装服务命令: mysqld –install
9,执行启动服务命令: net start mysql
10,到此,mysql就安装好了。 然后执行:mysql -uroot -p
11,输入刚才的密码:v2toK7w,TJ_<
12,执行改密码命令:set password = password(‘password’)
13,至此,就root账号的密码就被你改成password了