文章目录
1 MySQL下载。
下载链接:https://downloads.mysql.com/archives/community/
2 安装过程。
2.1 解压到指定路径。
2.2 添加环境变量。
2.3 新建my.ini配置文件。
[mysqld]
basedir=E:\mysql-5.7.28\
datadir=E:\mysql-5.7.28\data\
port=3306
skip-grant-tables
2.4 管理员模式启用cmd,安装MySQL服务。
C:\Windows\system32>cd /d E:\mysql-5.7.28\bin
E:\mysql-5.7.28\bin>mysqld -install
Service successfully installed.
2.5 初始化数据库文件。
E:\mysql-5.7.28\bin>mysqld --initialize-insecure --user=mysql
2.6 启动数据库。
E:\mysql-5.7.28\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
2.7 连接MySQL数据库。
E:\mysql-5.7.28\bin>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.28 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>
2.8 修改密码。
mysql> update mysql.user set authentication_string=password('123456') where user='root' and host='localhost';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> select user,host,authentication_string from mysql.user;
+---------------+-----------+-------------------------------------------+
| user | host | authentication_string |
+---------------+-----------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+---------------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)
2.9 刷新权限。
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
2.10 注释my.ini。
[mysqld]
basedir=E:\mysql-5.7.28\
datadir=E:\mysql-5.7.28\data\
port=3306
#skip-grant-tables
2.11 重启服务。
mysql> exit
Bye
E:\mysql-5.7.28\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
E:\mysql-5.7.28\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
2.12 重新连接。
E:\mysql-5.7.28\bin>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.28 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>