1、 获取mysql-5.7.34-winx64.zip,解压到F:\kindoapp
2、 在F:\kindoapp\mysql-5.7.34-winx64目录中创建my.ini并写入下面内容:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[mysqld]
#设置端口
port = 3206
basedir=F:\kindoapp\mysql-5.7.34-winx64
datadir=F:\kindoapp\mysql-5.7.34-winx64\data
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
max_connections = 800
max_connect_errors = 1000
max_allowed_packet = 1000M
innodb_file_per_table = 1
innodb_log_file_size=148M
innodb_page_size=32k
#skip-grant-tables 加这个参数关闭登录密码验证
3、以管理员身份运行cmd,依次执行下面命令
F:
cd F:\kindoapp\mysql-5.7.34-winx64\bin
.\mysqld.exe --initialize --console
.\mysqld.exe --initialize-insecure --user=mysql #初始为空密码
如果出现:
由于找不到MSVCR120.dll,无法继续执行代码.重新安装程序可能会解决此问题
需要下载安装 Visual C++ Redistributable Packages for Visual Studio 2013 x64
mysqld: Could not create or access the registry key needed for the MySQL application
to log to the Windows EventLog. Run the application with sufficient
privileges once to create the key, add the key manually, or turn off
logging for that application.
需要以管理员运行
到data目录查看.err文件,修复出现的错误,此文件中包括了root密码:
A temporary password is generated for root@localhost: h,go6w0oKche
.\mysqld.exe -install mysql57
net start mysql57
启动有问题,删除服务解决问题再重新安装
.\mysqld.exe -remove mysql57
4、 登录mysql
.\mysql --port 3206 -uroot -p
修改密码:
alter user 'root'@'localhost' identified by '123456';
grant all privileges on *.* to 'root'@'%' identified by '123456';
flush privileges;