windows安装多个mysql
下载mysql
配置mysql的文件
启动数据库
如何破解,修改数据库的用户名和密码
一:下载mysql
下载地址:
https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.43-winx64.zip
链接:https://pan.baidu.com/s/1kEFQ_AC56eFUnGwZ44NIwg
提取码:piq1
复制这段内容后打开百度网盘手机App,操作更方便哦
复制下面的文件:如图
我在c盘下面放了这些文件:创建了两个目录3306,3307,将这些文件放在下面:
C:\database\3307
C:\database\3306
二:修改配置文件
C:\database\3306\my-default.ini
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
port=3306
basedir=C:/database/3306
datadir=C:/database/3306/data
C:\database\3307\my-default.ini
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
port=3307
basedir=C:/database/3307
datadir=C:/database/3307/data
总结:配置文件只要修改三个内容:port ,basedir ,datadir
三:启动3306,3307的数据库
注意:cmd命令行需要以管理员的身份运行,管理员的权限
执行下面的命令启动3306的mysql
cd C:\database\3306\bin
mysqld install 3306 --defaults-file="C:\database\3307\my-default.ini"
net start 3306
mysql -u root
mysql> update mysql.user set password=password("123") where user="root" and host="localhost";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
执行下面的命令启动3306的mysql
cd C:\database\3307\bin
mysqld install 3307 --defaults-file="C:\database\3307\my-default.ini"
net start 3307
mysql -u root
mysql> update mysql.user set password=password("123") where user="root" and host="localhost";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
测试:
由于没有设置环境变量,所以测试的时候需要切换到bin目录下,使用mysql客户端的命令来测试数据库服务器是否可以连接,切换到3306或3307的任意一个bin目录下就可以了。
cd c:\database\3307\bin
mysql -u root -p -P 3307
mysql -u root -p -P 3307
四:如果你忘了自己数据库的用户名和密码:
你需要跳过授权表登录,就是不需要输入密码就可以进入数据库,然后通过sql命令修改数据库root的密码:
1:关闭mysql服务
net stop 3306
2:启动mysql服务
cd c:\database\3307\bin
mysql --skip-grant-tables
3:进入mysql
mysql -u root -p 直接回车,按enter键
4:修改密码
mysql> update mysql.user set password=password("123") where user="root" and host="localhost";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
5:杀掉这个mysql服务的进程
在2步骤直接按ctrl+c 就可以停止服务了
或者
tasklist | findstr mysql
taskkill /F /PID 进程的pid
这个命令适用于单个服务。
6:启动mysql服务
net start 3306
测试:略
7:补充添加字符编码:utf-8
[mysqld] character-set-server=utf8 collation-server=utf8_general_ci [client] default-character-set=utf8 [mysql] default-character-set=utf8
8:重新启动mysql服务3306,3307
c:\database\3306\bin>net stop 3306 3306 服务正在停止. 3306 服务已成功停止。 c:\database\3306\bin>mysqld --remove 3306 Service successfully removed. c:\database\3306\bin>mysqld install 3306 --defaults-file="c:\database\3306\my.ini" Service successfully installed. c:\database\3306\bin>net start 3306 3306 服务正在启动 . 3306 服务已经启动成功。 c:\database\3306\bin>mysql -u root -p123 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.43 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> show variables like "%char%" -> ; +--------------------------+----------------------------------+ | Variable_name | Value | +--------------------------+----------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | C:\database\3306\share\charsets\ | +--------------------------+----------------------------------+ 8 rows in set (0.00 sec) mysql> exit Bye c:\database\3306\bin>net stop 3307 3307 服务正在停止. 3307 服务已成功停止。 c:\database\3306\bin>mysqld --remove 3307 Service successfully removed. c:\database\3306\bin>mysqld --remove 3307 Service successfully removed. c:\database\3306\bin>mysqld install 3307 --defaults-file="c:\database\3307\my.ini" Service successfully installed. c:\database\3306\bin>net start 3307 3307 服务正在启动 . 3307 服务已经启动成功。 c:\database\3306\bin>mysql -u root -p123 -P 3307 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.43 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> show variables like "%char%"; +--------------------------+----------------------------------+ | Variable_name | Value | +--------------------------+----------------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | C:\database\3307\share\charsets\ | +--------------------------+----------------------------------+ 8 rows in set (0.00 sec) mysql> exit Bye
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!