#1、在mysql的安装目录中,新建data目录及my.ini#注意事项my.ini文件必须要用ansi的方式编码
#2、编辑my.ini
[mysqld]
basedir=D:\mysql-5.7.36-winx64
datadir=D:\mysql-5.7.36-winx64\data
port=3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character-set-server=utf8
character_set_filesystem=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
#3、将D:\mysql-5.7.36-winx64\bin路径添加到path中
#4.初始化数据库D:\mysql-5.7.36-winx64\bin>mysqld –initialize –user=mysql –console
2022-03-30T07:44:01.640992Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2022-03-30T07:44:01.641071Z 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.
2022-03-30T07:44:01.641079Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2022-03-30T07:44:02.890183Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-03-30T07:44:03.350137Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2022-03-30T07:44:03.496899Z 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: 2b9d5b48-affd-11ec-83b7-0250f2000002.
2022-03-30T07:44:03.537576Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-03-30T07:44:04.828539Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-03-30T07:44:04.828830Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-03-30T07:44:04.829738Z 0 [Warning] CA certificate ca.pem is self signed.
2022-03-30T07:44:06.375278Z 1 [Note] A temporary password is generated for root@localhost: V8uZTa!8fk.p
#【注意】记录随机生成密码 或 初始采用这条命令:mysqld initialize insecure –user=mysql –console
#5.启动服务mysql服务net start mysql
【帮助指南】
1、netstat -ano|findstr 3306
2、Windows下Mysql5.7忘记root密码的解决方法
- 打开第一个cmd窗口执行 net stop mysql57
- 在第一个cmd窗口执行 mysqld –defaults-file=”C:\ProgramData\MySQL\MySQL Server 5.7\my.ini” –skip-grant-tables —注意以你的路径为准
- 打开第二个cmd窗口执行 mysql -uroot -p 提示输入密码,直接回车(不用输入密码)
- 选择数据库:use mysql;
- 更新root的密码:update user set authentication_string=password(‘新密码’) where user=’root’ and Host=’localhost’;
- 刷新权限:flush privileges;
- 退出:quit
- 重新登录:mysql -uroot -p 提示输入密码,这时输入密码才能登录。完成!!!
【FQA】mysqld: [ERROR] Found option without preceding group in config file D:\mysql-5.7.36-winx64\my.ini at line 1!
没有新建库,需要建立一个库