Thursday, October 8, 2009

MySQL Instance Manager on phpMyAdmin

Last few days ago my friend ask me to install phpMyAdmin on CentOS 5.0 which in has installed MySQL Server. In our server the database/MySQL has many instance so mysql runs as MySQL Instance Manager.
Cause this is my first chase to install phpMyAdmin with MySQL Instance Manager, so i looking for how to install it.

On this server, Apache, php and MySQL Library must installed before if didn't install using yum :

yum install httpd mysql-share-community php-cli php-mbstring php-pdo phpMyAdmin php-common php php-devel php-mysql


After all those files install, then will get phpMyAdmin.conf on /etc/httpd/conf.d/ ;

# phpMyAdmin - Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
order deny,allow
deny from all
allow from 10.62.31.0/24

# This directory does not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#

Order Deny,Allow
Deny from All
Allow from None

# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc. This may break your mod_security implementation.
#
#
#
# SecRuleInheritance Off
#
#


Now we will configure to integrated MySQL Instance Manager with phpMyAdmin, first open /etc/my.cnf to see mysql configuration.
this is the example of mysql configuration :

[mysql.server]
use-manager
[manager]
default-mysqld-path = /usr/sbin/mysqld
socket = /db/log/manager.sock
pid-file = /db/log/manager.pid
password-file = /db/mysqlmanager.passwd
port = 1999
bind-address = 127.0.0.1
user = mysql
[mysqld]
port = 3306
user =mysql
server-id = 1
datadir = /db/testdb
socket = /db/testdb/mysql.sock
log-error = /db/log/mysql/testdb.log
pid-file = /db/log/mysql/testdb.pid
log-bin=/db/log/mysql/testdb-bin
sql-mode=STRICT_ALL_TABLES,ANSI_QUOTES,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE
skip-locking
key_buffer = 384M
max_allowed_packet = 1M
max_connections = 500
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
myisam_sort_buffer_size = 64M
thread_cache = 8
query_cache_size = 64M
query_cache_limit = 2M
thread_concurrency = 8
skip-bdb
table_cache = 8000
key_buffer_size = 6GB
read_buffer_size = 2M
max_heap_table_size = 1G
sort_buffer_size = 8K
join_buffer_size = 8K
thread_cache_size = 256
thread_stack = 256K
read_rnd_buffer_size = 16M
thread_concurrency = 8
query_cache_size = 64M
query_cache_limit = 2M
long_query_time = 0
tmp_table_size = 512M
default-storage-engine = INNODB
....


We just need part of [manager] which is path of socket socket = /db/testdb/mysql.sock.
Then phpMyadmin to integrate with mysql, open file config.inch.php usually on /etc/phpMyAdmin/ or /usr/share/phpMyAdmin folder.

Open your favorite editor (I usually using Vi) then find this part and set like this ;
Before :

$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';

After :

$cfg['Servers'][$i]['host'] = '192.168.0.99'; -->Your IP MySQL Server
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '/db/log/manager.sock';
$cfg['Servers'][$i]['connect_type'] = 'socket';


then save and exit ":wq".
Now restart your apache, then open your browser and input address http://192.168.0.99/phpMyAdmin, if show popup to input username and password of your MySQL Instance Manager. Your succeed....

Done

No comments: