Dec 02 2010
Advanced MRTG Configurations
Introduction
In many cases using MRTG in a basic configuration to monitor the volume of network traffic to your server isn’t enough. You may also want to see graphs of CPU, disk, and memory usage. This chapter explains how to find the values you want to monitor in the SNMP MIB files and then how to use this information to configure MRTG.
All the chapter’s examples assume that the SNMP Read Only string is craz33guy and that the net-snmp-utils RPM package is installed (see Chapter 22, “ Monitoring Server Performance“). Read more …
Only 3 simple steps ![]()
CREATE USER 'full_priv_username'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'full_priv_username'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;
Sep 22 2010
How to change all fields/tables to a different collation
This script will output the queries need to change all fields/tables to a different collation.
It is HIGHLY suggested you take a MySQL dump prior to running any of the generated
This code is provided as is and without any warranty
<?php
// this script will output the queries need to change all fields/tables to a different collation
// it is HIGHLY suggested you take a MySQL dump prior to running any of the generated
// this code is provided as is and without any warranty
die(”Make a backup of your MySQL database then remove this line”);
set_time_limit(0);
// collation you want to change:
$convert_from = ‘latin1_swedish_ci’;
// collation you want to change it to:
$convert_to = ‘utf8_general_ci’;
// character set of new collation:
$character_set= ‘utf8′;
$show_alter_table = true;
$show_alter_field = true;
// DB login information
$username = ‘username’;
$password = ‘password’;
$database = ‘database’;
$host = ‘localhost’;
mysql_connect($host, $username, $password);
mysql_select_db($database);
$rs_tables = mysql_query(” SHOW TABLES “) or die(mysql_error());
print ‘<pre>’;
while ($row_tables = mysql_fetch_row($rs_tables)) {
$table = mysql_real_escape_string($row_tables[0]);
// Alter table collation
// ALTER TABLE `account` DEFAULT CHARACTER SET utf8
if ($show_alter_table) {
echo(”ALTER TABLE `$table` DEFAULT CHARACTER SET $character_set;\r\n”);
}
$rs = mysql_query(” SHOW FULL FIELDS FROM `$table` “) or die(mysql_error());
while ($row=mysql_fetch_assoc($rs)) {
if ($row['Collation']!=$convert_from)
continue;
// Is the field allowed to be null?
if ($row['Null']==’YES’) {
$nullable = ‘ NULL ‘;
} else {
$nullable = ‘ NOT NULL’;
}
// Does the field default to null, a string, or nothing?
if ($row['Default']==’NULL’) {
$default = ” DEFAULT NULL”;
} else if ($row['Default']!=”) {
$default = ” DEFAULT ‘”.mysql_real_escape_string($row['Default']).”‘”;
} else {
$default = ”;
}
// Alter field collation:
// ALTER TABLE `account` CHANGE `email` `email` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL
if ($show_alter_field) {
$field = mysql_real_escape_string($row['Field']);
echo “ALTER TABLE `$table` CHANGE `$field` `$field` $row[Type] CHARACTER SET $character_set COLLATE $convert_to $nullable $default; \r\n”;
}
}
}
?>
Jul 19 2010
How to DISABLE ipv6 in CentOS5 System
# ifconfig
eth1 Link encap:Ethernet HWaddr 00:1C:F0:BB:A7:28
inet addr:10.10.10.11 Bcast:10.10.10.255 Mask:255.255.255.0
inet6 addr: fe80::21c:f0ff:febb:a728/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:470449435 errors:1 dropped:0 overruns:0 frame:0
TX packets:464084402 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2563674692 (2.3 GiB) TX bytes:2243518951 (2.0 GiB)
Interrupt:225 Base address:0×2800
Jul 11 2010
Scripting a MySQL InnoDB Engine Conversion
0) Backup your database.
You should probably be doing this already. Now’s a good time to make sure that your backups ran.
1) Create the script.
You’ll need the correct permissions to query the database. Here’s the command. Be sure to change <DATABASE_NAME> as it fits.
# mysql -p -e "show tables in <DATABASE_NAME>;" | \
tail --lines=+2 | \
xargs -i echo "ALTER TABLE {} ENGINE=INNODB;" > alter_table.sql
2) Run the script.
# mysql --database=<DATABASE_NAME> -p < alter_table.sql
3) Verify it by running this command in mysql:
mysql> show table status;