Ning Ma blog

my technology tips


MySQL’s query cache vs memcached

I did some research about MySQL’s query cache. Some people said it will speed up page load times by 5-15%. Query cache is used to cache SELECT results and later return them without actual executing the same query once again. Having the query cache enabled may result in significant speed improvements, But if tables change […]

check mysql tem files and tables

Try to execute show processlist;, maybe there are some long lasting threads that were not killed for some reason. Similarly execute SHOW SESSION STATUS LIKE ‘Created%’; to check if mysql hasn’t created to many temporary tables. Server restart automatically closes all open temp tables and kills threads, so the application might run quicker.

dump and import mysql database avoid error codes

Do not do this, since it might screw up encoding:

Better do:

Note that when your MySQL server is not set to UTF-8 you need to do mysqldump –default-character-set=latin (!) to get a correctly encoded dump. If you only want to dump the structure without data, use

Importing a dump safely Do […]

php very useful mysql connect function for small project

This class is very useful for small projects, it easy and fast to connect mysql with php script. Thank you Ciprian Mocanu to provide this document. The Class:

Example usage:

mysql production server and development sync

UPDATE! Code moved to bitbucket: Often times, you need to pull down an up-to-date version of Magento from your production server to your development or staging servers. This involves: Executing a mysqldump on production. Zipping it up. Secure copying the zipped file from production to development (or staging). Unzipping the file locally. Updating the […]

Memory Game

Game link: Download Demo: “Memory game is a card game in which all of the cards are laid face down on a surface and two cards are flipped face up over each turn. The object of the game is to turn over pairs of matching cards.” I used half day to program this […]

Choosing innodb_buffer_pool_size

Innodb Buffer Pool is by far the most important option for Innodb Performance and it must be set correctly. I’ve seen a lot of clients which came through extreme sufferings leaving it at default value (8M). So if you have dedicated MySQL Box and you’re only using Innodb tables you will want to give all […]

Move a whole lamp site to another server

1. tar all folder

2. backup mysql DB

3.scp files from ssh to another server

4. restore the DB

5. tar gz file

6. Update httpd.conf 7. chown -Rf permissions 8. update DNS nameserver or ip

How to copy a mysql database using mysqldump

1. Back-up the original database that you want to “clone” In case you you have a mysql password for user root you need to use mysql(dump) -u root -p dbname and you will be asked for root password by mysql program. If you don’t wish to be asked you can youse mysql(dump) -u root -ppassword […]

MYSQL5 event scheduler example

MySQL 5.1 Event Scheduler, Conceptually, this is similar to the idea of the UNIX crontab (also known as a “cron job”) or the Windows Task Scheduler. What is “Event Scheduler” event is an object whose statements are executed in response to the passage of a specified time interval. An event performs a specific action according […]

Previous Posts