Windows下安装MySQL8详细教程

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

Windows下安装MySQL8详细教程

因为需要在Windows下安装MySQL8的数据库做一个临时数据库环境。

1.准备软件

使用社区版本下载地址如下
https://dev.mysql.com/downloads/mysql/
使用8.0.16版本需要在归档中查找
在这里插入图片描述
选择版本

在这里插入图片描述

下载mysql-8.0.16-winx64.zip 即可

2.安装软件

mysql-8.0.16-winx64.zip解压后就是MySQL的应用目录不需要install操作直接配置环境变量即可。

1配置路径

解压后将目录软件目录放在 D:\Program Files\mysql-8.0.16-winx64
在用户环境变量中设置
在这里插入图片描述
在系统环境变量path中增加mysql的bin路径
在这里插入图片描述

2创建data

注意必须以管理员运行
快捷键打开先win+r 输入cmd将下一步点击Enter 换为Ctrl+Shift+Enter直接以管理员打开cmd窗口。
在这里插入图片描述

mysqld --initialize-insecure --user=mysql
结果
Service successfully installed.

3安装MySQL

执行

mysqld -install

4启动MySQL服务

执行
net start MySQL
结果如下

MySQL 服务正在启动 …
MySQL 服务已经启动成功。

5修改密码

登录mysql因为之前没设置密码所以密码为空不用输入密码直接回车即可 。

C:\Windows\system32>mysql -uroot -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 8.0.16 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

修改密码

alter user 'root'@'localhost' identified with mysql_native_password by 'mysql123456';
flush privileges;  

3.处理问题

1无法访问MySQL

快捷键打开先win+r 输入services.msc打开服务控制台手工重启MySQL服务。再重新访问数据库。

2Python无法访问MySQL

Python访问MySQL数据库提示

pymysql.err.OperationalError: (1370, "execute command denied to user ‘root’@‘%’ for routine

原因非MySQL本地用户访问没有访问权限。
解决方法如下

create user 'root'@'%' identified with mysql_native_password by 'mysql123456';

grant all privileges on *.* to 'root'@'%' ;

flush privileges;  
阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: windowsmysql