Spaceship222
Spaceship222

Reputation: 849

How to create new server in mysql on windows?

I installed mysql 8.0. During the process of install, it will guide you to create a server that is registered as window service. For example, by default it will put server related file on the (base)path "C:\ProgramData\MySQL\MySQL Server 8.0" using default port 3306. What if I want to create another server?What should I do? Maybe using mysqld --initialize?

Upvotes: 0

Views: 1671

Answers (1)

mZed
mZed

Reputation: 359

Well make sure you have installed a running and properly configured MySQL Server and Instance. If so, copy the data directory of your running MySQL Instance (Server) in a second folder.

Existing Folder: C:\ProgramData\MySQL\MySQL Server 5.7
New Folder (for example): C:\ProgramData\MySQL\MySQL second Server 5.7

NEXT: Create 2 Option-Files (a ka .txt files, you save as my-opts[Optummber.cnf)]. You may create one file named C:\ProgramData\MySQL\my-opts1.cnf that looks like this:

File 1 Content:

    [mysqld]
    datadir = C:\ProgramData\MySQL\MySQL Server 5.7\mydata1
    port = 3307

Create a second file named C:\ProgramData\MySQL\my-opts2.cnf that looks like this:

    [mysqld]
    datadir = C:\ProgramData\MySQL\MySQL second Server 5.7\mydata2
    port = 3308

NEXT: Use the --defaults-file option to start each server, runnig on its own option file:

     C:\> C:\ProgramData\MySQL\bin\mysqld --defaults-file=C:\ProgramData\MySQL\my-opts1.cnf

     C:\> C:\ProgramData\MySQL\bin\mysqld --defaults-file=C:\ProgramData\MySQL\my-opts2.cnf

Note: Each will start visibly, with a new prompt until the server exits later), so you will need to issue those two commands in separate console windows.

To shut down the servers, connect to each using the appropriate port number:

     C:\> C:\ProgramData\MySQL\bin\mysqladmin --port=3307 --host=127.0.0.1 --user=root --password shutdown

     C:\> C:\ProgramData\MySQL\bin\mysqladmin --port=3308 --host=127.0.0.1 --user=root --password shutdown

Servers configured as just described permit clients to connect over TCP/IP. - If you want to do so, please follow the guide on: https://dev.mysql.com/doc/refman/8.0/en/multiple-windows-command-line-servers.html

Note: I wrote the commands in here based on https://dev.mysql.com/doc/refman/8.0/en/multiple-windows-command-line-servers.html. Please modify them according to your file System and MySQL Configuration. I don't take any warranty for them. If the used filepaths seem to complicated for you, please change them to the eased up versions in the linked description. Setting up mySQL Instances might be a challenging process, just do so, if you can handle it.

Upvotes: 2

Related Questions