mysql-8.0.17-winx64.zip的安装

一.下载

https://dev.mysql.com/downloads/mysql/

二.解压保存

    路径:D:\software\mysql-8.0.17-winx64
将路径D:\software\mysql-8.0.17-winx64\bin
加入环境变量

三.配置文件my.imi


 1. 在路径:D:\software\mysql-8.0.17-winx64下新建my.imi文件,文件内容如下:::
 	[client]
default-character-set=utf8

[mysqld]
port = *
basedir=D:\software\mysql-8.0.17-winx64
#datadir=D:\software\mysql-8.0.17-winx64\bin
#max_connections=200
#character-set-server=utf8
#default-storage-engine=INNODB

# 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:\software\mysql-8.0.17-winx64
# 数据文件存放目录
  datadir = D:\software\mysql-8.0.17-winx64\data
# 端口,默认3306  
  port = 3306
# 服务实例的唯一标识
# server_id = MySQL

# 允许最大连接数
  max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
  max_connect_errors=10
# 服务端使用的字符集默认为utf8
  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=utf8

[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306   
default-character-set=utf8

四.安装mysql服务

以管理员的身份运行终端输入命令::msyqld -install

五.在目录下D:\software\mysql-8.0.17-winx64新建data文件

以管理员的身份运行终端输入命令::mysqld --initialize -insecure
执行完上述命令后再目录:D:\software\mysql-8.0.17-winx64会生成一个新的文件夹:data

六,启动服务

以管理员的身份运行终端输入命令::net start mysql
注意:如果出现无法启动,请删除data文件夹重新执行新建data文件的命令步骤

七.进入mysql服务

找到初始密码:
在D:\software\mysql-8.0.17-winx64\data\admin-PC.err文件中
generated for root@localhost: tVAJmnjp0#&4
mysql -u root -p
密码:tVAJmnjp0#&4
进入mysql中后修改密码:ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

八.在用Navicat Premium 12连接本地数据库时会报错如下

mysql-8.0.17-winx64.zip的安装_第1张图片

  1. 原因:mysql8.0之前的版本加密规则是mysql_native_password,mysql8.0之后,加密规则是caching_sha2_password
  2. 解决办法:
	1.查看默认加密方式
			use mysql;
			select user,plugin from user where  user = 'root';
	2.修改加密方法:

		LTER USER'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
	3.更新密码:
	ALTER USER'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; 
	4.刷新权限:FLUSH PRIVILEGES;

你可能感兴趣的:(mysql)