|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Changing localhost IP address for MySQL
I am moving a bunch of my database sites to a new server. I have to keep the databases hot durring the switch. Is there a way to change the IP address of 'localhost' to another IP address when you connect in PHP to MySQL? That way I wouldn't have to change 'localhost' to the new IP address on every script.
Thanks In Advance! ![]() Sam Powers |
|
#2
|
|||
|
|||
|
yes, there is. But youŽd rather not.
"localhost" is used by many services and programs to connect to other services and programs on the same machine. you could do something in your /etc/hosts like changing "127.0.0.1 localhost" to "192.168.1.10 localhost" but you better do a full-text search-and-replace to the FQDN if you donŽt want to **** up the system or if you donŽt own the machine you do this on: for i in /home/myname/*.php; do cat "$i"|sed -e "s/localhost/mynewname/g" > "/tmp/phptmp"; cat /tmp/phptmp >"$i"; done; rm -f /tmp/phptmp using bash. (make backups BEFORE!) and: use mysql; update hosts set host="your-name.de" where host="localhost"; and then tell mysql to reload the grant tables. (mysqladmin is your friend...) (dont use this literally. i am at home right now and dont have mysql running on my new system yet!!!) using Win****? - dont do it. weŽll find another solution. |
|
#3
|
||||
|
||||
|
Thanks. I own both the machines - the one I am currently using and the one I am moving to, and they are both running Linux, just like at home. Linux all the way, baby!!! Down with Microgay!!
This isn't a PHP question, but I forgot how to do a search and replace on all the files in a directory from the Kernel... do you think you could help me on that one? Thanks Again! Sam Powers |
|
#4
|
|||
|
|||
|
this is not a kernel but a bash question.
see the "for i in ..." line. i think this is what you are asking for. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > Changing localhost IP address for MySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|