欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Windows10下安装mysql8 zip版

程序员文章站 2022-07-06 21:49:10
...

结合多篇博客文档整理:
Mysql.zip安装步骤:
1、解压mysql.zip到想要存放的位置,我的位置E:\Tools\mysql8
2、添加系统环境变量
Windows10下安装mysql8 zip版

3、在mysql8目录下新建my.ini文件
文件内容如下:
其中的basedir和datadir路径根据各自的需求配置

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/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.

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
character-set-server=utf8
# set basedir to your installation path
basedir=e:/Tools/mysql8
# set datadir to the location of your data directory
datadir=e:/Tools/mysql8/MysqlData
# bind-address
skip-grant-tables

# 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 = .....
# datadir = .....
# port = .....
# server_id = .....

# 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 

4、数据库初始化
以管理员身份打开cmd窗口,切换到mysql8的bin目录下
执行命令:mysqld --initialize --console初始化

5、注册mysql服务到windows服务中
以管理员身份打开cmd窗口,切换到mysql8的bin目录下
执行命令:mysqld --install [服务名]

6、关闭MySQL服务
Cmd仍然在bin目录下,执行命令net stop mysql8 (mysql8是上一步第5步中注册的服务名)

7、跳过mysql密码验证
Cmd在bin目录下,执行命令mysqld --console --skip-grant-tables --shared-memory
完毕后cmd窗别关

8、无密码进入mysql
以管理员身份再开一个cmd窗口,进到bin目录,执行mysql -u root -p,提示输入密码,直接回车键,进入mysql

9、将密码置空
依次执行
use mysql; (使用mysql数据表)
update user set authentication_string=’’ where user=‘root’;(将密码置为空)
quit; (然后退出Mysql)

10、更改为自己的密码
关闭第一个cmd窗;
将my.ini中的skip-grant-tables注释掉;
在第二个窗口中执行net stop mysql(关闭mysql服务,虽然会显示没有开启服务,但是以防万一)
net start mysql(再打开mysql服务)
(这里不要嫌麻烦,如果上一个mysql服务没关闭,我们依旧是无密码登陆)

Cmd进到bin目录,执行mysql -u root -p
(此处会显示输入密码,直接回车就好了,第四步我们已经将他置为空了)
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘新密码’;(更改密码)

11、验证密码是否修改成功
接着上面的窗口继续输入:
quit;(退出mysql)
mysql -u root -p
提示输入密码,输入新密码,再次登录 成功~~~

相关标签: mysql