一、安装前准备
1、下载免安装版本mysql-8.0.12-winx64
2、配置环境变量
MYSQL_HOME=D:\LYN\mysql\mysql-8.0.12-winx64
PATH=%MYSQL_HOME%\bin
3、添加配置文件my.ini
4、在安装目录下创建data目录
二、安装
1、用管理员的身份打开命令符窗口(cmd);切换至D:\LYN\mysql\mysql-8.0.12-winx64\bin目录;
2、输入命令
mysqld --initialize //初始化data目录
mysqld --install //安装mysql
net start mysql //启动mysql服务
mysql -u root -P3386 -p //登录到mysql,密码在(data/*.err)文件中
3、修改用户登录密码
alter user 'root'@'localhost' identified by '970131';
flush privileges;//刷新
*****************************************************************************************************************
三、注意
1、mysql8.0密码采用了新的加密方式caching_sha2_password,这种加密方式在使用cmd的登录是没有问题的,但是现在大多数客户端还没有更新,比如我用的navicat就连接不上(也可能我的版本太低)。
所以在配置文件中加了一条配置,即:
默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
2、如果您在初始化数据库的时候忘记了加上述配置,导致客户端无法连接数据库
可以在修改密码的时候显示指定加密插件。
**************************************************************************************************************************
四、mysql8免安装版卸载
1、regedit命令,打开注册表
删除以下文件(有的可能没有):
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/Eventlog/Applications/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/Services/Eventlog/Applications/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Eventlog/Applications/MySQL
2、打开cmd.exe
执行 sc delete mysql
***************************************************************************************************************
四、mysql8初始密码位置
mysql8初始密码位置在data目录下err结尾的文件中;
2018-08-16T02:12:16.981810Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: fqqistj1#riZ
五、my.ini
# 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.
[mysqld]
#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.
# mysql根目录
basedir = D:\LYN\mysql\mysql-8.0.12-winx64
# 数据文件存放目录
datadir = D:\LYN\mysql\mysql-8.0.12-winx64\data
# 端口,默认3306
port = 3386
# 服务实例的唯一标识
# server_id = MySQL
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character_set_server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
# 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
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3386
default-character-set=utf8mb4