本文为安装配置部分
记录本人mysql安装过程出现的问题 可以找找是不是因为自己也出现了这个问题
下载mysql-8.0.19-winx64.zip
本人使用的mysql版本为8.0.19
mysql下载地址:https://dev.mysql.com/downloads/mysql/
提示:以下是本篇文章正文内容,仅介绍了.zip格式且下面案例可供参考
安装
-
.zip格式的MySQL安装文件直接解压即可,进行环境变量配置后即可使用
-
解压后目录如下:
配置
1.环境变量
-
此电脑右击
-
下滑至底部,点击高级系统设置
-
点击页面下方的环境变量
-
配置用户变量
:点击用户变量的path,点击新建 把你解压后的mysql \ bin路径添加进来E:\college\mysql-8.0.19-winx64\bin
这个是我的目录 -
配置系统变量
:点击新建后,输入变量名:MYSQL_HOME
变量值:就是你.zip文件解压的目录
-
一路点击确定键
地下是文字叙述的图解
2.添加配置文件my.ini
配置完环境变量之后,需要新建一个my.ini的配置文件
文件内容为:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
# 设置3306端口
port = 3306
# 注意这里应该是你的目录
tmpdir=E:/college/mysql-8.0.19-winx64/data
# 设置mysql的安装目录 注意这里应该是你的目录
basedir = E:/college/mysql-8.0.19-winx64
# 设置mysql数据库的数据的存放目录 注意这里应该是你的目录
datadir = E:/college/mysql-8.0.19-winx64/data
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 创建模式
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
3.cmd
-
以管理员身份打开cmd
-
利用cd命令进入bin目录下
C:\Users\惠普>e: E:\>cd E:\college\mysql-8.0.19-winx64\bin E:\college\mysql-8.0.19-winx64\bin>
-
E:\college\mysql-8.0.19-winx64\bin>mysqld --remove Service successfully removed.
- 如果
mysqld --remove
是用于删除原来的mysql的如果没有第一次安装原来没有则出现:E:\college\mysql-8.0.19-winx64\bin>mysqld --remove The service doesn't exist!
- 如果
-
E:\college\mysql-8.0.19-winx64\bin>mysqld --install MySQL Service successfully installed. E:\college\mysql-8.0.19-winx64\bin>mysqld --initialize --console 2022-10-21T10:53:10.958512Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release. 2022-10-21T10:53:10.958583Z 0 [System] [MY-013169] [Server] E:\college\mysql-8.0.19 winx64\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progress as process 44660 2022-10-21T10:53:10.959825Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 2022-10-21T10:53:12.926716Z 5 [Note] [MY-010454] [Server] A temporary password is generated or root@localhost: =Nqazly&L3ds E:\college\mysql-8.0.19-winx64\bin>net start MySQL MySQL 服务正在启动 . MySQL 服务已经启动成功。
root@localhost: =Nqazly&L3ds
是我的密码,记住你的密码
- 进入
输入上面你记住的密码Enter password:
E:\college\mysql-8.0.19-winx64\bin>mysql -uroot -p Enter password: ************ Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.19 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.
注意 :
- 所用的命令有:
sql mysqld --remove
移除删除mysqld --install MySQ
安装mysqld --initialize --console
初始化net start MySQL
开启mysql -uroot -p
进入exit
退出
修改密码
由于随机生成的密码过于繁琐,所以一般会修改一下
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
修改成功后显示:
Query OK, 0 rows affected (0.02 sec)
退出:
mysql> exit;
Bye
可以再次尝试一下是否密码修改成功
E:\college\mysql-8.0.19-winx64\bin>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.19 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.
mysql> exit;
Bye
至此完成mysql的安装。