当前位置:Gxlcms > 数据库问题 > windows安装mysql

windows安装mysql

时间:2021-07-01 10:21:17 帮助过:10人阅读


title: windows安装mysql

windows安装mysql

1.下载mysql


mysql国内镜像链接:http://mirrors.sohu.com/mysql/MySQL-8.0/
`
技术图片

2.安装mysql


下载完成,双击msi
技术图片


技术图片


技术图片


技术图片


技术图片


选择你要安装的路径:

技术图片


技术图片


3.配置环境变量

技术图片


技术图片


在安装Mysql根目录新建my.ini文件:
技术图片
文件内容如下:

[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:/software\MySQL\MySQL Server 8.0
# 设置mysql数据库的数据的存放目录
datadir=D:/software\MySQL\MySQL Server 8.0\Data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
#mysql_native_password
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set=utf8mb4

在bin目录打开cmd
技术图片


配置mysql

输入: mysqld --initialize --console
技术图片
生成了临时密码:a9fZitC47j,u


以管理员身份打开cmd窗口,cd到mysql的安装目录:
技术图片


mysqld --install

技术图片


net start mysql

技术图片


连接MySQL、修改密码

mysql -u root -p #密码就是刚才生成的随机密码
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘新密码‘;
exit;
D:\software\MySQL\MySQL Server 8.0>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11

Copyright (c) 2000, 2018, 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 BY ‘root‘;
Query OK, 0 rows affected (0.08 sec)

mysql> exit;
Bye

配置完成!

windows安装mysql

标签:blog   color   efault   引擎   存储   shadow   插入   character   新建   

人气教程排行