windows安装mysql
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