需要更多色彩的
不是代码,而是生活

Windows10安装mysql8.0绿色版详细教程

1.下载mysql。官方下载页面是https://dev.mysql.com/downloads/mysql/,找到最下面,如下图,点击红色方框中的按钮进入下载页面。

点击“No thanks, just start my download.”开始下载。

2.下载完成后,解压。我这里解压到C:\mysql-winx64,如下图

3.创建配置文件。在mysql目录下即C:\mysql-winx64创建一个my.ini文件,内容一般如下即可,其中,数据库文件目录即datadir=D:\MySql\data是用于存放mysql存储的数据的,可以根据自己需要进行修改,要确保这个目录是已经存在的,且内文件夹内没有任何文件。如果不写,默认会在mysql目录下生成一个data文件夹存放数据。

# 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.

# 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 

[client]
#mysql客户端端口
port=3306
#客户端默认文本编码使用utf-8
default-character-set=utf8
[mysqld]
#mysql服务端口
port=3306
#mysql服务默认文本编码使用utf-8
character_set_server=utf8
#mysql目录,即解压的目录
basedir=C:\mysql-winx64
#数据库文件目录
datadir=D:\MySql\data
#修改sql_mode,使用严格sql模式
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[WinMySQLAdmin]
#mysqld位置
C:\mysql-winx64\bin\mysqld.exe

4.安装服务,以管理员身份运行命令提示符,进入到C:\mysql-winx64\bin,然后输入命令mysqld install,如果回显“Service successfully installed.”,则mysql服务安装成功。

5.初始化。继续执行命令mysqld --initialize --console,此时可能会稍微等待一会,如下图,红框中是生成的默认密码,保存下来。

6.启动mysql。在任务管理器的服务选项卡中,找到MySql,右键选择“开始”,启动MySql服务。

7.登录mysql。如果MySql服务正常启动了,此时便可以使用root用户和上面生成的密码登录mysql了。登录命令为“mysql -u root -p”,如下图。

8.修改root密码。执行sql

alter user 'root'@'localhost' identified by 'newpassword';

重新加载权限表,使密码修改立即生效。

flush privileges;

9.配置MySQL允许外部访问

use mysql;
update user set host = '%' where user ='root';

10.防火墙入站规则里添加3306端口。

11.如果用sqlyog等工具登录mysql时出现“plugin caching_sha2_password could not be loaded...”这样的问题,参见 http://www.codezd.com/experience/85.html

赞(1) 打赏
未经允许不得转载:代码一线 » Windows10安装mysql8.0绿色版详细教程
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

觉得文章有用就支持一下本站

支付宝扫一扫打赏

微信扫一扫打赏