resolve Emoji Emotion symbols when save to mysql<5.5

1. what’s Emoji Emotion symbols: it’s usually post by iPhone client;

2. when the content include a Emoji from API, it’s always a [] like “[]晚安俩宝”, actually it is a moon emotion, but when you insert it into a utf-8 mysql database , you will get a warning as: “Incorrect string value: ‘\xF0\x9F\x94\x8E’ for column ‘line’ at row 1.

The string ‘\xF0\x9F\x91\x8A, actually is a 4-byte unicode: u’\U0001f62a’, but utf-8 database could not accept a 4-byte, mysql under 5.5.3 don’t support 4-byte unicode.

3. using re.compile method you could replace all the 4-byte unicode to something you want.

>>> import re
>>> highpoints = re.compile(u'[\U00010000-\U0010ffff]')
>>> example = u'Some example text with a sleepy face: \U0001f62a'
>>> highpoints.sub(u'[我是笑脸]', example)
u'Some example text with a sleepy face:[我是笑脸] '

here the "\U0001f62a" is just a Emoji smile face.
you can print that in python shell to confirm that.
4. if still can't print, check your Locale settings by tpye: locale
be sure to set :
or you can type below to make the session take effect
export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'

mysql 自动备份 脚本  最新版 点这里下载


1. 修改文件里的配置部分包括访问mysql的用户名密码,要备份的数据库,备份地址,发送邮件的地址(默认使用postfix):

    # Username to access the MySQL server e.g. dbuser

	# Password to access the MySQL server e.g. password

	# Host name (or IP address) of MySQL server e.g localhost

	# List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3"

	# Backup directory location e.g /backups

	# Mail setup
	# What would you like to be mailed to you?
	# - log   : send only log file
	# - files : send log file and sql files as attachments (see docs)
	# - stdout : will simply output the log to the screen if run manually.
	# - quiet : Only send logs if an error occurs to the MAILADDR.

	# Set the maximum allowed email size in k. (4000 = approx 5MB email [see docs])

	# Email Address to send mail to? (



2. 给脚本增加可执行权限

[cce]chmod +x /root/[/cce]
crontab e

#格式为dom=day of month
#m h  dom mon dow   command

0 0 * * 1 /var/www/sqlback/

# for redhat
yum install postfix

# for ubuntu
apt-get install postfix