window系统安装MYSQL8.0版本完整版
window系统安装mysql8.0完整版
!!!!本人修改了mysql的端口号3308,可以自己修改my.ini文件中的配置
一、下载两个版本的MySQL
进入官网下载:https://www.mysql.com/
二、将下载下来的压缩包放到合适的位置并且解压缩
注意:此处先解压安装MySQL8时再解压8.0版本(要不然容易出问题)
配置环境变量
安装MySQL8
1、先创建my.ini文件
# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# On Windows you should keep this file in the installation directory
# of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
# make sure the server reads the config file use the startup option
# "--defaults-file".
#
# To run run the server from the command line, execute this in a
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# To install the server as a Windows service manually, execute this in a
# command line shell, e.g.
# mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# And then execute this in a command line shell to start the server, e.g.
# net start MySQLXY
#
#
# Guildlines for editing this file
# ----------------------------------------------------------------------
#
# In this file, you can use all long options that the program supports.
# If you want to know the options a program supports, start the program
# with the "--help" option.
#
# More detailed information about the individual options can also be
# found in the manual.
#
#
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]
port=3308
[mysql]
default-character-set=utf8
# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]
# The TCP/IP Port the MySQL Server will listen on
port=3308
#Path to installation directory. All paths are usually resolved relative to this.
basedir="D:/workmenus/MySQL8/MySQL8/mysql-8.0.19-winx64"
#Path to the database root
datadir="D:/workmenus/MySQL8/MySQL8/mysql-8.0.19-winx64/Data/"
# 允许最大连接数
max_connections=10000
# 允许最大连接人数
max_user_connections=1000
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 连接时间
wait_timeout=31536000
interactive_timeout=31536000
2、生成data文件夹
以管理员身份打开cmd命令提示符,切换到MySQL8的 bin 路径下。
输入命令:mysqld --initialize
等一段时间,它会重新生成一个 Data 文件夹
同样找到.err文件,找到对应生成的随机密码
3、安装MySQL8服务
在命令行输入 (名字命名为MYSQL8,并且指定默认的配置文件为刚才创建的my.ini文件)
mysqld --install MYSQL8 --defaults-file=D:\workmenus\MySQL8\MySQL8\mysql-8.0.19-winx64\my.ini
4、开启MySQL8服务
在命令行输入 net start MYSQL8
5、登录MYSQL8,并且修改密码
(1)登录输入:mysql -u root -P 3308 -h localhost -p
密码输入 .err文件里的生成的随机密码
(2)修改密码输入:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
6、链接成功