win10安装免安装版的mysql5.7
本文讲解的是win10下配置并安装免安装版的mysql5.7
准备
win10 64位
安装包mysql-5.7.29-winx64
解压缩
我这里将压缩包,解压缩我的D盘;解压后完整的路径为:D:\MyDeveloper\mysql-5.7.29-winx64
新建文件夹:data
新建一个文件:my.ini
当前目录的结构如下:
├── mysql-5.7.29-winx64
│ ├── bin
│ ├── data
│ ├── docs
│ ├── include
│ ├── lib
│ ├── LICENSE
│ ├── my.ini
│ ├── README
│ └── share
配置my.ini
配置my.ini文件,内容如下:
[mysqld]
basedir ="D:\MyDeveloper\mysql-5.7.29-winx64"
datadir ="D:\MyDeveloper\mysql-5.7.29-winx64\data"
port=3306
server_id=10
character-set-server=utf8
character_set_filesystem=utf8
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
[client]
port=3306
default-character-set=utf8
[mysqld_safe]
timezone="CST"
[mysql]
default-character-set=utf8
安装
配置环境变量
环境变量的Path中,新建一个,将mysql的bin目录加进去,如下图:
执行安装
以管理员的方式运行powershell
依次执行:mysqld --install
mysqld --inlstall
提示安装成功即可。
执行:mysqld --initialize-insecure --user=mysql
mysqld --initialize-insecure --user=mysql
没有输出表示安装成功
启动服务
执行: net start mysql 启动mysql的服务,输出的内容如下:
PS C:\Windows\system32> net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
配置root密码
登录
使用: mysql -u root -p 进行登录,输入完成后敲回车;提示你输入密码,不用管,直接再次回车即可;输入的内容如下:
PS 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.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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.
设置密码
登录成功后,切换数据库:use mysql
mysql> use mysql
Database changed
更新数据库密码:update user set authentication_string=password(‘root’) where user=‘root’;
mysql> update user set authentication_string=password('root') where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
退出:quit
mysql> quit
Bye
重新启动,依次执行:net stop mysql 和net start mysql
PS C:\Windows\system32> net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
PS C:\Windows\system32> net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
再次登录,这个时候需要输入密码了,如下:
PS 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.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, 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.