1. 登录
mysql -uroot -p --default-character="utf8"
2. 备份
mysqldump -uroot -p --default-character="utf8" database > /home/jhat/Documents/database.sql
3. 恢复
mysql -uroot -p --default-character="utf8" < /home/jhat/Documents/database.sql
其中--default-character="utf8"
是相当重要的,否则很容易出现乱码!!!
4. 添加用户
grant all privileges on *.* to jhat@localhost identified by 'jhat' with grant option;