【通过zip方式安装mysql服务】

通过zip方式安装mysql服务

Mysql安装包下载

通过访问mysql官网下载:mysql下载地址

mysql安装及环境配置

1.解压缩

下载完成后,解压到合适的安装位置:E:\servers\mysql-8.0.37-winx64

配置环境变量

复制解压的位置,来配置环境变量

右键此电脑->属性->高级系统设置->高级->环境变量->新建系统变量

  1. 新建MYSQL_HOME
  2. 新增PATH配置(本来就有) %MYSQL_HOME%\bin

初始化mysql配置

  1. 配置文件:在mysql安装路径下新建文件my.ini进行一些默认配置,注意basedir是mysql安装位置,datadir是数据存放地址,可以手动新建data文件夹

    [client]
    port=3306
    default-character-set=utf8
    [mysqld]
    bind-address=127.0.0.1
    skip-networking=0
    basedir=E:/servers/mysql-8.0.37-winx64
    datadir=E:/servers/mysql-8.0.37-winx64/data
    port=3306
    character_set_server=utf8mb4
    sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
    explicit_defaults_for_timestamp=true

  2. 通过管理员权限启动cmd:mysqld --initialize --user=mysql --console
    **注意在输出的最后一行提供了mysql的初始密码不要忘了保存
    我的是7hgRquaQkM)n **

    C:\Windows\System32>mysqld --initialize --user=mysql --console
    2024-10-08T01:40:50.701999Z 0 [System] [MY-013169] [Server] E:\servers\mysql-8.0.37-winx64\bin\mysqld.exe (mysqld 8.0.37) initializing of server in progress as process 15404
    2024-10-08T01:40:50.715118Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2024-10-08T01:40:50.993325Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2024-10-08T01:40:51.990600Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 7hgRquaQkM)n

安装mysql服务

继续在cmd窗口输入命令mysqld --install

复制代码
C:\Windows\System32>mysqld --install
Service successfully installed.

启动MySQL服务

看到上面的安装成功提示就可以启动了,继续在cmd窗口键入:net start mysql

复制代码
C:\Windows\System32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

连接mysql

看到启动成功提示,输入命令 mysql -u root -p然后输入刚才的密码

复制代码
C:\Windows\System32>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.37

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

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>

修改root用户密码

成功进入mysql命令行后,在mysql>命令行输入命令alter user root@localhost identified by 'root';

复制代码
mysql> alter user root@localhost identified by 'root';
Query OK, 0 rows affected (0.02 sec)

mysql>

密码就被修改为root了 下次登陆使用新密码就可以了

相关推荐
junnhwan10 分钟前
【苍穹外卖笔记】Day04--套餐管理模块
java·数据库·spring boot·后端·苍穹外卖·crud
川石课堂软件测试20 分钟前
全链路Controller压测负载均衡
android·运维·开发语言·python·mysql·adb·负载均衡
一枚正在学习的小白28 分钟前
PG数据文件位置迁移
linux·运维·服务器·数据库
真的想不出名儿44 分钟前
上传头像到腾讯云对象存储-前端基于antdv
java·数据库·腾讯云
Dreams_l1 小时前
初识redis(分布式系统, redis的特性, 基本命令)
数据库·redis·缓存
数据库知识分享者小北1 小时前
Qoder + ADB Supabase :5分钟GET超火AI手办生图APP
数据库·后端
hjbf1 小时前
理解并解决 MySQL 中的 "You can't specify target table for update in FROM clause" 错误
mysql
一路向北_Coding1 小时前
MyBatis Generator让你优雅的写SQL
mysql·mybatis
点亮一颗LED(从入门到放弃)2 小时前
SQLite3数据库——Linux应用
linux·数据库·sqlite
济南java开发,求内推2 小时前
mongodb一个服务器部署多个节点
服务器·数据库·mongodb