วันพุธที่ 19 พฤศจิกายน พ.ศ. 2551

เปลี่ยน port mysql ใน AppServ

ในที่นี้ เนื่องจาก ติดตั้ง mysql 2 instance บนเครื่องเดียวกัน
และ มีการ ใช้ port ชนกันจึงต้องเปลี่ยน ที่ ตัวหนึ่้ง
( หลังจาก มีการเปลี่ยน port ของ apache web server ไปแล้ว )
โดยให้ instance ตัวหนึ่ง ใช้ port 3306 ปกติ
และอีกตัว ใช้ port 3307

ต้องการเปลี่ยน port ก็ แก้โดย
C:\AppServ\MySQL\my.ini

เปลี่ยน section
[client]
port=3306

ให้กลายเป็น
[client]
port=3307

และต้องเปลี่ยน phpMyAdmin อีกให้ มองเห็นตัวนี้ รวมทั้ง เมื่อจะติดต่อด้วย php
ต้องเรียกด้วย
$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
หรือ
$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');


แก้ไข ที่ phpMyAdmin ดังนี้
C:\AppServ\www\phpMyAdmin
config.inc.php แก้ไข จาก

cfg['Servers'][$i]['port'] = '';

ให้เป็น
cfg['Servers'][$i]['port'] = '3307';

แล้ว ลอง start mysql ใหม่
และ start phpmyadmin ใหม่ จาก browser

ถ้าทำการเปลี่ยน port ของ apache ต้อง restart apache ใหม่ด้วยครับ

ไม่มีความคิดเห็น: