Monday, January 31, 2011
Moving your mysql database to another hard disk
Thursday, December 17, 2009
We are using MySQL, help save it
Tuesday, July 21, 2009
Maatkit: A great MySQL toolbox
You can use Maatkit to prove replication is working correctly, fix corrupted data, automate repetitive tasks, speed up your servers, and much, much more.
Maatkit is sponsored by Percona, who releases it under the GPL and offers paid support and sponsorship of new features. Maatkit is hosted on Google Code and free support is available in the Maatkit Discuss Google Group.
What can Maatkit do and more can be read on the website.
Jeremy Zawodny highlights a few of his favorite utilities here.
Monday, April 13, 2009
postfix can't connect to MySQL
Apr 13 17:34:53 webmail postfix/smtpd[6726]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Apr 13 17:34:53 webmail postfix/smtpd[6726]: NOQUEUE: reject: RCPT from rv-out-0506.google.com[209.85.198.233]: 451 4.3.0: Temporary lookup failure; from= to= proto=ESMTP helo=
I got a reference to MySQL database in my main.cf which triggered the error:
local_recipient_maps = mysql:/etc/postfix/sql-recipients.cf
#service type private unpriv chroot wakeup maxproc command + args
smtp inet n - y - - smtpd
So I changed the line to:
#service type private unpriv chroot wakeup maxproc command + args
smtp inet n - n - - smtpd
Voila!. It worked. See log below:
Apr 13 18:03:02 webmail postfix/smtpd[7039]: connect from rv-out-0506.google.com[209.85.198.239]
Apr 13 18:03:03 webmail sqlgrey: grey: domain awl match: updating 209.85.198(209.85.198.239), gmail.com
Apr 13 18:03:03 webmail postfix/smtpd[7039]: B3246A3075: client=rv-out-0506.google.com[209.85.198.239]
Apr 13 18:03:04 webmail postfix/cleanup[7042]: B3246A3075: message-id=<23c8d5620904130314j7f4c619di57c7d8c0d217ed62@mail.gmail.com>
Apr 13 18:03:04 webmail postfix/qmgr[7033]: B3246A3075: from=, size=2277, nrcpt=1 (queue active)
Apr 13 18:03:05 webmail postfix/smtpd[7046]: connect from webmail.myfakedomain.net[127.0.0.1]
Apr 13 18:03:05 webmail postfix/smtpd[7046]: 26BBFA3076: client=rv-out-0506.google.com[209.85.198.239]
Apr 13 18:03:05 webmail postfix/cleanup[7042]: 26BBFA3076: message-id=<23c8d5620904130314j7f4c619di57c7d8c0d217ed62@mail.gmail.com>
Apr 13 18:03:05 webmail postfix/qmgr[7033]: 26BBFA3076: from=, size=2751, nrcpt=1 (queue active)
Apr 13 18:03:05 webmail postfix/smtpd[7046]: disconnect from webmail.myfakedomain.net[127.0.0.1]
Apr 13 18:03:05 webmail dbmail/lmtpd[20480]: Message:[serverchild] serverchild.c,PerformChildTask(+349): incoming connection from [127.0.0.1] by pid [20480]
Apr 13 18:03:05 webmail postfix/lmtp[7043]: B3246A3075: to=, relay=127.0.0.1[127.0.0.1]:10025, delay=2, delays=0.96/0.01/0/1, dsn=2.0.0, status=sent (250 2.0.0 Ok, id=01032-05, from MTA([127.0.0.1]:10026): 250 2.0.0 Ok: queued as 26BBFA3076)
Apr 13 18:03:05 webmail postfix/qmgr[7033]: B3246A3075: removed
Sunday, February 25, 2007
Tips for MySQL
Some tips of using MySQL on Linux
Login to MySQL using mysql client in console/terminal:
mysql -u username -p dbname
or
mysql -u username -ppassword dbname
or (using current username to log in)
mysql -ppassword dbname
security tip: username root is the default administrator. Do not use it in a live environment. Create a new one and set the appropriate permission for it.
Create a new database:
mysqladmin -u username -ppassword create databasename
(username is the administrator username that able to create a new database ie root)
or you can log in to mysql using mysql client in console. Example:
//create table with myisam engine.
CREATE TABLE mytable (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
value_a TINYINT
) TYPE=MYISAM
//create table with HEAP engine.
CREATE TABLE mytable (
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
value_a TINYINT
) TYPE=HEAP
Delete a database:
Login to mysql and issue command drop database databasename.
(Make sure you use usernames with correct priviledge to drop a database)
What is the size of my database?
database size = the sum of all table sizes + all index sizes
- Open a text editor (eg. Notepad)
- Copy and paste the code below into your text editor ( replace username, password and dbid accordingly):
mysql database sizeif ($filesize < filesize ="">
# in at least kilobytes.
for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024;
$file_size_info['size'] = ceil($filesize);
$file_size_info['type'] = $bytes[$i];
return $file_size_info; } $db_server = 'mysqlhost'; $db_user = 'username'; $db_pwd = 'password'; $db_name = 'dbid';
$db_link = @mysql_connect($db_server, $db_user, $db_pwd)
or exit('Could not connect: ' . mysql_error()); $db = @mysql_select_db($db_name, $db_link) or exit('Could not select database: ' . mysql_error());
// Calculate DB size by adding table size + index size:
$rows = mysql_query("SHOW table STATUS"); $dbsize = 0;
while ($row = mysql_fetch_array($rows)) {$dbsize += $row['Data_length'] + $row['Index_length']; } print "database size is: $dbsize bytes "; print 'or';
$dbsize = file_size_info($dbsize); print "database size is: {$dbsize['size']} {$dbsize['type']}"; ?>
put this php script into your accessible directory. (taken from here).
Nice reading : Overcoming MySQL's 4GB limit by Jeremy Zawodny.
To know what engine your database is using:
SHOW TABLE STATUS FROM yourdbname
ALTER TABLE isamtable CHANGE TYPE=InnoDB
or you can use utility mysql_convert_table_format :
mysql_convert_table_format --user=username --pasword=password --type=innodb databasename tables
Tuesday, February 21, 2006
Migrating mails from old server to new server
1. backup (using mysqldump)
~#mysqldump -u user -pPassword dbmail > dbmail.sql
2. restore
~#mysql -u user -pPassword dbmail < dbmail.sql
Voila. It's done!.
I have users' preferences and address books saved in database too. So the method of backing up and restoring to the new server should be the same.
Nvidia new hotplug feature on Linux
If you use nvidia driver for your GPU, you probably wonder why in some config, you can't hotplug your second monitor. You need to reboo...
-
BASH script to load balance 2 WAN links. #!/bin/bash # # bal_local Load-balance internet connection over two local links # # Version: 1....
-
queuegraph is a very simple mail statistics RRDtool frontend for Postfix that produces daily, weekly, monthly and yearly graphs of Postfix...
-
Recently, my server's only hard disk was almost full. I bought a new hard disk with bigger size and I decided to just add it as a second...