1.设定已建立表的字符集
alter database cms520 character set gbk;
2.建数据库并设置字符集
create database cms520 character set gbk; 
创建数据库用
create database cms62cheia default character set utf8 default collate utf8_unicode_ci;
3.建用户
grant all on cufecms61.* to cufecms61@'localhost' identified by "cufecms61" WITH GRANT OPTION;
GRANT ALL ON samp_db.* TO max@'%' IDENTIFIED BY "diamond"
GRANT ALL PRIVILEGES ON *.* TO 'sjwsb'@'%' IDENTIFIED BY 'sjwsb' WITH GRANT OPTION;

查看用户
select user,host,password from mysql.user;
4.查看数据库字符集
SHOW VARIABLES LIKE 'character_set_%';
默认的字符集都是latinn1的,这个时候,你需要将latin1转换成gb2312,方法如下

CODE:
[Copy to clipboard]
mysql> set NAMES 'gbk';
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_database=gbk;
Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_server=gbk;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'character%';
 SHOW CHARACTER SET;可查出可供使用的所有字符集。
 SHOW VARIABLES LIKE 'character_set';可查出服务器的默认字符集。
SHOW CREATE DATABASE cms520;可查出数据库级的字符集

两条命令可查出数据表的字符集。

    SHOW CREATE TABLE cms_log
    SHOW TABLE STATUS LIKE 'cms_log';
以下几命令可查出数据列的字符集:

    DESCRIBE table_name;
    SHOW COLUMNS FROM table_name;
    SHOW CREATE TABLE table_name;


mysql -h 192.168.1.199 -u root -p harmony2003mysql

查看MYSQL版本
\s
重启
/etc/init.d/mysql   restart 
启动
./mysqld_safe -user=mysql
数据库导出
 mysqldump -h 192.168.1.235 -u cms520 -pcms520 cms520 > /database/a.sql
数据库导入
mysql -h 192.168.1.235 -u cms520 -pcms520 --default-character-set=utf8 test < /database/a.sql
执行脚本
source /home/mysql5.2.1.sql


D:\Gpower\MySQL\MySQL Server 5.0\bin>mysqldump --opt --default-character-set=utf8 --user=cms520 --password cms53>d:/Gpower/cms53.sql

修改数据库字段名
alter table tablename change old new int;

linux设定大小写不敏感
你需要在配置文件my.cnf的 [mysqld] 区段下增加一行 lower_case_table_names=1


alter table CMS_CONTENTPROPERTY change stringValue stringValue longtext null;