零 修订记录
序号 | 修订内容 | 修订时间 |
---|---|---|
1 | 新增 | 2022/4/20 |
一 摘要
本文主要介绍win10 下安装mysql
二 环境信息
2.1 操作系统
2.2 软件信息
数据库版本:mysql-5.7.26-winx64
三 实施
3.1 安装 msyql
3.1.1 解压到安装目录
略
我这里解压到 C:\develop\mysql-5.7.26-winx64
3.1.2 新建my.ini
在该目录C:\develop\mysql-5.7.26-winx64下新建my.ini
内容如下
[client]
port=3306
default-character-set=utf8
[mysqld]
# 设置为自己MYSQL的安装目录
basedir=C:\\develop\\mysql-5.7.26-winx64
# 设置为MYSQL的数据目录
datadir=C:\\develop\\mysql-5.7.26-winx64\\data
port=3306
character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
#开启查询缓存
explicit_defaults_for_timestamp=true
skip-grant-tables
3.1.2 新建data
在C:\develop\mysql-5.7.26-winx64 目录下 新建data 文件夹
3.1.3 配置环境变量
直接在path 里新增mysql 的bin 地址
3.1.4 初始化mysql
3.1.4.1 生成初始化文件
需要cmd 以管理员身份运行
mysqld --initialize
该步骤执行成功 会在data 文件夹下生成相关文件
3.1.4.2 安装mysql 服务
Microsoft Windows [版本 10.0.17763.1577]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Windows\system32>mysqld --initialize
C:\Windows\system32>mysqld install
Service successfully installed.
C:\Windows\system32>
3.1.4.3 启动mysql
Microsoft Windows [版本 10.0.17763.1577]
(c) 2018 Microsoft Corporation。保留所有权利。
C:\Windows\system32>mysqld --initialize
C:\Windows\system32>mysqld install
Service successfully installed.
C:\Windows\system32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
C:\Windows\system32>
也可以在服务里手工器动
3.1.4.4 修改root 密码
C:\Windows\system32>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26 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> use mysql
Database changed
mysql> update user set authentication_string=PASSWORD('123456') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql>
然后修改my.ini,删除skip-grant-tables
[client]
port=3306
default-character-set=utf8
[mysqld]
# 设置为自己MYSQL的安装目录
basedir=C:\\develop\\mysql-5.7.26-winx64
# 设置为MYSQL的数据目录
datadir=C:\\develop\\mysql-5.7.26-winx64\\data
port=3306
character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER
#开启查询缓存
explicit_defaults_for_timestamp=true
重启myql
C:\Windows\system32>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
C:\Windows\system32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
检查必须使用123456 才能登录
再次修改密码
alter user user() identified by “123456”;
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user user() identified by "123456";
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>
3.1.5 客户连接数据库
略