2009-07-04 95 views
3

我想在同一臺機器的兩個不同端口上使用MySQL服務器。我做了兩個單獨的配置文件。當我試圖連接到我定義的第二個端口上的MySQL服務器時,我無法連接。運行MySQL的操作系統是Windows Vista。我也嘗試在指定端口後從命令行啓動mysqld在mysql中運行多個mysql實例

這是示例文件,我已經改變了MySQL服務器從兩個不同的端口爲:

# CLIENT SECTION 
# ---------------------------------------------------------------------- 
# 
# The following options will be read by MySQL client applications. 
# Note that only client applications shipped by MySQL are guaranteed 
# to read this section. If you want your own MySQL client program to 
# honor these values, you need to specify it as an option during the 
# MySQL client library initialization. 
# 
[client] 

port=3306 

[mysql] 
mysql-path="C:\Program Files\MySQL\MySQL Server 5.1\bin" 
default-character-set=latin1 

[client] 

port=3307 

[mysql1] 
mysql1-path="C:\Program Files\MySQL2\MySQL Server 5.1\bin" 
default-character-set=latin1 

# SERVER SECTION 
# ---------------------------------------------------------------------- 
# 
# The following options will be read by the MySQL Server. Make sure that 
# you have installed the server correctly (see above) so it reads this 
# file. 
# 
[mysqld] 
mysqld-path="C:\Program Files\MySQL\MySQL Server 5.1\bin\" 

# The TCP/IP Port the MySQL Server will listen on 
port=3306 

#Path to installation directory. All paths are usually resolved relative to this. 
basedir="C:/Program Files/MySQL/MySQL Server 5.1/" 

#Path to the database root 
datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data/" 
# 
server_id=1 

[mysqld1] 
# The TCP/IP Port the MySQL Server will listen on 
port=3307 
server_id=2 
mysqld1-path="C:\Program Files\MySQL2\MySQL Server 5.1\bin\" 

#Path to installation directory. All paths are usually resolved relative to this. 
basedir="C:/Program Files/MySQL2/MySQL Server 5.1/" 

#Path to the database root 
datadir="C:/ProgramData/MySQL2/MySQL Server 5.1/Data/" 
# 
# The default character set that will be used when a new schema or table is 
# created and no character set is defined 
default-character-set=latin1 

# The default storage engine that will be used when create new tables when 
default-storage-engine=INNODB 

# Set the SQL mode to strict 
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" 
+0

你想運行兩個MySQL實例(每個都有自己的一套數據庫),或只是一個? – BryanH 2009-07-04 06:08:27

+0

是的,我想運行它們自己的一組數據庫的mysql實例 – 2009-07-04 09:16:10

+0

@MySQLDBA,不應該在http://serverfault.com? – Pacerier 2015-08-21 11:39:25

回答

0

您還需要指定不同的datadir的命令(即其中包含數據庫文件的目錄) -線。您不能在不同的實例中打開相同的數據庫,因爲它們會互相鎖定和/或導致數據損壞。

+0

嗨,我不想打開相同的數據庫。但我無法創建兩個實例,雖然我指定了不同的datadir。我需要爲此做些什麼。我的意思是我需要添加--default-extra-file除了默認文件 – 2009-07-04 10:16:00