windows安装多个mysql

windows安装多个mysql

下载mysql

配置mysql的文件

启动数据库

如何破解,修改数据库的用户名和密码

一:下载mysql

下载地址:

https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.43-winx64.zip

复制下面的文件:如图

我在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

测试:略

猜你喜欢

转载自www.cnblogs.com/lzjloveit/p/10634285.html