MySQL 解压版在Windows下的安装与配置

从 MySQL 官网下载解压版本的安装包

下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads

点击直接下载5.7.24版本:https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-winx64.zip

下载完成后解压到安装位置,我的安装位置为

D:\database\mysql-5.7.24

D:\database\mysql-5.7.24 目录下新建配置文件 my.ini

[mysql]
default-character-set=utf8
[mysqld]
port = 3306
basedir=D:\database\mysql-5.7.24
datadir=D:\database\mysql-5.7.24\data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB

5.7.24 版本安装包已不包含 my.default.ini 配置文件和 data 目录。

data 目录不要新建,my.ini 配置文件可以新建,data 目录通过初始化命令来创建。

以管理员的方式打开 cmd 命令窗口,进入 D:\database\mysql-5.7.24\bin 目录下执行以下命令,初始化数据库。

D:\database\mysql-5.7.24\bin>mysqld --initialize --console
2018-11-05T09:09:27.549968Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-11-05T09:09:29.253650Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-11-05T09:09:29.850310Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-11-05T09:09:30.180265Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 80b77eb4-e0da-11e8-ac91-5215d904abe2.
2018-11-05T09:09:30.225972Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-11-05T09:09:30.244958Z 1 [Note] A temporary password is generated for root@localhost: T%loP7wOUdOz

mysqld --initialize 会随机生成临时密码 T%loP7wOUdOz

配置 MySQL 为Windows 服务

mysqld install 

管理员的身份运行 CMD,启动 MySQL

net start|stop mysql
[root@localhost mysql]# mysql -u root -pT%loP7wOUdOz
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.24

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> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
## 首次登陆需要修改root用户密码
mysql> alter user 'root'@'localhost' identified by 'root';或者alter user user() identified by 'root';
Query OK, 0 rows affected (0.00 sec)

## 配置root用远程登陆且具有所有库的权限
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值