Mysql数据库常用操作
1.备份数据库
[root@bj-db-x86v-app01 ~]# mysqldump -h 192.168.0.8 -uroot -p‘123456‘ user >user.sql
2.查看mysql数据库字符集设置
mysql> show variables like ‘character_set_%‘;
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
3.更改数据库的字符集
mysql> alter database opensips default character set ‘utf8‘;
4.创建数据库时指定字符集
mysql> create databse opensips character set utf8 collate utf8_general_ci;
5.在mysql的配置文件/etc/my.cnf中指定创建的数据库的默认字符集
[mysqld]
default-character-set=utf8
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
default-character-set=utf8
本文出自 “云人生” 博客,请务必保留此出处http://ovcer.blog.51cto.com/1145188/1430465
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。