MySQL Windows安装配置
一、简介
系统:Windows10
MySQL:mysql-5.6.24-win32.zip(https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.24-win32.zip)
https://downloads.mysql.com/archives/community/
二、安装配置启动
安装步骤:
- 下载压缩包;在安装目录解压。
配置步骤:
- 环境变量:右键此电脑,属性,高级,系统环境变量,path,添加解压目录的bin目录。例如:D:\install\mysql-5.6.24-win32\bin
- MySQL配置文件:配置文件my-default.ini,复制一份重命名为:my.ini。my.ini配置如下:
1 [mysqld] 2 # 设置3306端口 3 port=3306 4 # 设置mysql的安装目录 5 basedir=D:\install\mysql-5.6.24-win32 6 # 设置mysql数据库的数据的存放目录 7 datadir=D:\install\mysql-5.6.24-win32\Data 8 # 允许最大连接数 9 max_connections=200 10 # 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统 11 max_connect_errors=10 12 # 服务端使用的字符集默认为UTF8 13 character-set-server=utf8 14 # 创建新表时将使用的默认存储引擎 15 default-storage-engine=INNODB 16 # 默认使用“mysql_native_password”插件认证 17 default_authentication_plugin=mysql_native_password 18 # 防止group by带来的一系列问题 19 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 20 [mysql] 21 # 设置mysql客户端默认字符集 22 default-character-set=utf8 23 [client] 24 # 设置mysql客户端连接服务端时默认使用的端口 25 port=3306 26 default-character-set=utf8
数据初始化启动(cmd右键管理员运行)
- 数据初始化:mysqld –initialize
- 注册到注册表添加MySQL服务:mysqld –install
- MySQL启动:net start mysql
- MySql服务停止:net stop mysql
- MySql服务删除:mysqld -remove mysql
执行历史记录:
1 C:\Windows\system32>d: 2 3 D:\>cd D:\install\mysql-5.6.24-win32\bin 4 5 D:\install\mysql-5.6.24-win32\bin>mysqld --initialize 6 2022-06-04 23:10:55 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 7 2022-06-04 23:10:55 0 [Warning] 'ERROR_FOR_DIVISION_BY_ZERO' is deprecated and will be removed in a future release. 8 2022-06-04 23:10:55 0 [Warning] 'NO_ZERO_DATE' is deprecated and will be removed in a future release. 9 2022-06-04 23:10:55 0 [Warning] 'NO_ZERO_IN_DATE' is deprecated and will be removed in a future release. 10 2022-06-04 23:10:55 0 [Note] mysqld (mysqld 5.6.24) starting as process 6660 ... 11 12 D:\install\mysql-5.6.24-win32\bin>mysqld --install 13 Service successfully installed. 14 15 D:\install\mysql-5.6.24-win32\bin>net start mysql 16 MySQL 服务正在启动 . 17 MySQL 服务已经启动成功。 18 19 20 D:\install\mysql-5.6.24-win32\bin> 21 D:\install\mysql-5.6.24-win32\bin>mysql -uroot -p 22 Enter password: 23 Welcome to the MySQL monitor. Commands end with ; or \g. 24 Your MySQL connection id is 1 25 Server version: 5.6.24 MySQL Community Server (GPL) 26 27 Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. 28 29 Oracle is a registered trademark of Oracle Corporation and/or its 30 affiliates. Other names may be trademarks of their respective 31 owners. 32 33 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 34 35 mysql> exit 36 Bye
MySQL密码设置:
1 #mysq 5.7之前版本 2 mysql> UPDATE user SET password=PASSWORD(“new password”) WHERE user='username'; 3 4 #mysql 5.7及之后版本: 5 mysql> UPDATE user SET authentication_string=PASSWORD(“new_password”) WHERE user='root'; 6 7 //刷新系统权限表 8 mysql> FLUSH PRIVILEGES; 9
MySQL删除用户名为空的用户:
MySQL允许远程登陆:
三、重置密码
- 管理员启动cmd(确定MySQL添加path并且注册注册表)
- 关闭mysql:net stop mysql
- 输入:mysqld --shared-memory --skip-grant-tables
- 直接进入MySQL登陆:mysql
- 输入:FLUSH PRIVILEGES;
- 更改密码:update mysql.user set password=password("123456") where user="root";
- 输入:FLUSH PRIVILEGES;
- 启动MySQL:net start mysql
- mysql -u root -p
四、相关参考
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具