【通过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了 下次登陆使用新密码就可以了

相关推荐
程序新视界8 小时前
MySQL中什么是回表查询,如何避免和优化?
mysql
薛定谔的算法13 小时前
phoneGPT:构建专业领域的检索增强型智能问答系统
前端·数据库·后端
Databend14 小时前
Databend 亮相 RustChinaConf 2025,分享基于 Rust 构建商业化数仓平台的探索
数据库
得物技术15 小时前
破解gh-ost变更导致MySQL表膨胀之谜|得物技术
数据库·后端·mysql
Java水解16 小时前
【MySQL】从零开始学习MySQL:基础与安装指南
后端·mysql
Raymond运维20 小时前
MariaDB源码编译安装(二)
运维·数据库·mariadb
沢田纲吉20 小时前
🗄️ MySQL 表操作全面指南
数据库·后端·mysql
RestCloud1 天前
SQL Server到Hive:批处理ETL性能提升30%的实战经验
数据库·api
RestCloud1 天前
为什么说零代码 ETL 是未来趋势?
数据库·api
ClouGence2 天前
CloudCanal + Paimon + SelectDB 从 0 到 1 构建实时湖仓
数据库