Install and run two mysql database instances bitsCN.com on one server
Install and run two mysql database instances on one server
To facilitate the test, we want to use two mysql database instances. Take windows as an example
Of course, installing the first mysql database is simple. But you need to install it again. when you run the mysql installation program, a prompt will be displayed, fixed, uninstalled, and re-installed.
Download a free-of-installation mysql, zip file.
Click "open link" and select "ZIP Archive". select "32-bit" and "64-bit" based on the system.
I downloaded the mysql-5.5.20-winx64, downloaded and decompressed to get a mysql-5.5.20-winx64 folder,
There is no my. ini file in it, but there are many different. INI files. Select a my-medium.ini, and copy a copy and rename it to my. ini.
Open and modify the port. if the previous mysql has used 3306, change it to an unused one, such as 3308;
[Client] # password = your_password port = 3308 socket = mysql5 default-character-set = utf8 # Here follows entries for some specific programs [mysqld] should be changed below port = 3308 socket = mysql5 skip-external-locking key_buffer_size = 16 M bytes = 1 M table_open_cache = 64 sort_buffer_size = 512 K net_buffer_length = 8 K read_buffer_size = 256 K bytes = 512 K bytes 8 M
Add the data directory after this;
# Path to installation directory. All paths are usually resolved relative to this. basedir = "D:/mysql/" --------- this is the directory of the folder you extract. # Path to the database root datadir = "D:/mysql/data /"
In the specified character set, you can ignore it if not needed.
Add default-character-set = utf8 under [client;
Add character-set-server = utf8 under [mysqld;
My. ini is configured.
The installation service is available,
Open cmd and cd to D:/mysql/bin "---------. this is the Directory of the folder you extracted.
> D:/mysql/bin> mysqld -- install mysql5.5 -- defaults-file = "D:/mysql/my. ini"
Press Enter ???? ?? Service successfully installed. the installation is complete. (Uninstall mysqld remove mysql5.5)
Mysqld -- install mysql5.5 (name of this service, for example, mysql2,) -- defaults-file = "D:/mysql/my. ini"
After the service is installed, start mysql5.5 in the service, or in the command prompt, net start mysql5.5, after the service is started
> D:/mysql/bin> mysql-uroot-P3308
Press enter to connect to the mysql database.
Mysql-uroot-P3308, which is a password-free installation, can be set later.-P is capital P, and 3307 is the port number.
You can set a password.
Run the following command
Mysql> use mysql; mysql> update user set password = password ("123456") where user = "root"; mysql> flush privileges; mysql>/q; -- exit,
Restart the service,
Connect with the password again.
> D:/mysql/bin> mysql-uroot-P3308-p
If you have any questions, you may encounter them;
After the service is installed, the service mysql5.5 or net start mysql5.5 cannot be started in the control panel. if my. ini has no error.
Use the console command to start the service.
> D:/mysql/bin> mysqld -- start the console Command
Port: 3308 indicates that the service is started.
BitsCN.com