tags:

views:

624

answers:

3

I wont to add to mysql other tcp port that he will be lessen to
and i will be able to connect to that port from my application

i have duplicate my appliction and i runing them both from the same machine
they both connected to the mysql server that are running on the same machine
the problem is that the default port 3306 all ready taken

thanks

A: 

A single mysql instance can host multiple databases. So an alternative for you is that each application connects to the same mysql instance running at port 3306, but each uses a different database name.

Journeyman Programmer
this will not solve my problem they bouth need to share the same data but the problem is that the port can not be shared by 2 processes
Shvilam
+3  A: 

You cannot bind mysqld to listen to multiple ports. The only way you can achieve this is with internal routing rules which would forward the target port to 3306.

If you are on linux, you can achieve this using iptables. iptables is a bundle of fun normally reserved for system administrators though.

Is there a reason why both copies of your application can't connect to the same port 3306? Normally you should be able to have any number of clients connecting.

zombat
A: 

You can do that with something like this:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 9005 -j REDIRECT --to-port 9000

Where eth0 is your network dev, 9005 is your "source port", and 9000 the port where your service is running. Oh, that example is for TCP protocol only.

You can find more examples about port redirection here. Useful site for Linux, btw.

altuzar