Windows install multiple mysql

Installing multiple mysql is actually very simple, and there is a lot of online information. I will sort it out and join in the fun.

1. Download mysql zip and extract it to the specified directory. I have 3 here, and more are similar

d:\mysql1

d:\mysql2

d:\mysql3

2. Modify the configuration file, my.ini, some versions do not have it, you need to create it manually, some are my-default.ini, change it to my.ini, if there is no data folder, create a data folder

The basic content is as follows, some too much content is temporarily unavailable:

[mysqld]
basedir=d:\mysql2
datadir=d:\mysql2\data 
port = 3307
character-set-server=utf8
server_id = 2
#Used when you forget your password
#skip-grant-tables
#Modify the authentication method
#default_authentication_plugin=mysql_native_password
[mysql]
default-character-set=utf8

The important modification is port and server_id. By default, if port is not set, it is 3306. Here are set respectively: 3306, 3307, 3308, and the corresponding server_id are 1, 2, and 3 respectively.

Save after modification.

 

3. Initialize mysql

Run the command prompt as an administrator, enter the bin directory of mysql2, and enter the following command

mysqld --initialize --console

A random password will be generated here. Please keep in mind that if you forget it accidentally, delete all the data under data and reinitialize it again. For details, please refer to my other blog ---- mysql8.0 installation needs to change the password to allow remote connection.

 

4. Install mysql

mysqld --install mysql2

The mysql2 here is the service name used to distinguish multiple mysqls in the service. If not written, the default is MySQL, and multiple databases are installed. If not written, the service cannot be started.

 

5. Start mysql2

net start mysql2

Normally it should start successfully. If startup fails, it is important to check that you have configured environment variables .

If you configure environment variables for all three mysqls, the system will default to the first one to be valid. At this time, you need to modify the registry. The modification method is as follows:

ctrl+r, enter regeidt in the box that appears, and press Enter to enter the registry interface.

Find and hit the following directory: HKEY_LOCAL_MACHINE–>SYSTEM–>CurrentControlSet–>Services 
Find the mysql2 you just created, and ImagePath defaults to the mysqld of the database where you configured the environment variable. You don’t need to delete it, just add this sentence after:

--defaults-file="d:\mysql2\my.ini" mysql2

Then go to start. (The last mysql2 is the service name you specified when you installed it. If it is not mysql2, please change it to your own service name, followed by the path)

 

6. To install multiple mysql, it is not recommended to configure environment variables. Although it is more convenient to operate on the command line and do not need to go to the bin directory, it is only valid for one, and the others still need to go to the corresponding bin directory. The most important thing is, In addition to configuring the environment variable mysql, the rest of mysql needs to modify the registry to start normally.

 

7. When installing multiple mysql logins, please indicate the port, the first port is uppercase, and the latter password is lowercase

mysql -uroot -P3307 -p

 At this point, the installation of multiple mysql under windows is completed. You want to install several installations, isn't it very simple!

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325071474&siteId=291194637