Monday, March 29, 2010

[Level 2] The script for get MySQL configuration.

If you want to check about MySQL configuration,
you can try this script.
#!/usr/bin/bash
sUserHome=~
for file in `my_print_defaults  | grep \/etc\/my\.cnf`
do
  file=`echo $file | sed -e "s|~|$sUserHome|"`
  echo "-------------------------------------------------------------------"
  echo "{$file}"
  perl -ne 'm/^([^#][^\s=]+)\s*(=.*|)/ && printf("%-35s%s\n", $1, $2)' `echo $file`
  echo "-------------------------------------------------------------------"
  echo ""
done

After run it:
# ./showMyCnf.sh
-------------------------------------------------------------------
{/etc/my.cnf}
[mysqld]                          
log                               
innodb-file-per-table             
-------------------------------------------------------------------

-------------------------------------------------------------------
{/etc/mysql/my.cnf}
[client]                          
port                               = 3306
socket                             = /tmp/mysql.sock
[mysqld]                          
port                               = 3306
socket                             = /tmp/mysql.sock
skip-locking                      
key_buffer_size                    = 16K
max_allowed_packet                 = 1M
table_open_cache                   = 4
sort_buffer_size                   = 64K
read_buffer_size                   = 256K
read_rnd_buffer_size               = 256K
net_buffer_length                  = 2K
thread_stack                       = 128K
server-id                          = 1
[mysqldump]                       
quick                             
max_allowed_packet                 = 16M
[mysql]                           
no-auto-rehash                    
[myisamchk]                       
key_buffer_size                    = 8M
sort_buffer_size                   = 8M
[mysqlhotcopy]                    
interactive-timeout               
-------------------------------------------------------------------

-------------------------------------------------------------------
{/usr/local/mysql/etc/my.cnf}
Can't open /usr/local/mysql/etc/my.cnf: No such file or directory.
-------------------------------------------------------------------

-------------------------------------------------------------------
{/src/SolarisApps/mysql-5.1.44-solaris10-x86_64/my.cnf}
Can't open /src/SolarisApps/mysql-5.1.44-solaris10-x86_64/my.cnf: No such file or directory.
-------------------------------------------------------------------

-------------------------------------------------------------------
{/home/stanley/.my.cnf}
Can't open /home/stanley/.my.cnf: No such file or directory.
-------------------------------------------------------------------


Wish this helps.

regards,
Stanley Huang