mysql数据库管理-创建数据库

mysql建数据库的字符集与排序规则说明

创建数据库mysql

create schema arsystem default character set gbk collate gbk_chinese_ci;

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON ARSYSTEM.* TO [email protected]'%' IDENTIFIED BY "123";

 

C:\Users\Administrator>mysql -h localhost -u arsystem -p123
ERROR 1045 (28000): Access denied for user 'arsystem'@'localhost' (using passwor
d: YES)

C:\Users\Administrator>mysql -h localhost -u aradmin -p123
ERROR 1045 (28000): Access denied for user 'aradmin'@'localhost' (using password
: YES)

C:\Users\Administrator>mysql -h localhost -u ARADMIN -p123
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.0.77-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON ARSYSTEM.* TO [email protected]'%' IDENTIFIED BY "123";

C:\Users\Administrator>mysql -h localhost -u aradmin -p123
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 45
Server version: 5.0.77-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| arsystem           |
+--------------------+
2 rows in set (0.00 sec)

mysql>


1.字符集说明:

mysql数据库管理-创建数据库

一般选择utf8.下面介绍一下utf8与utfmb4的区别。

utf8mb4兼容utf8,且比utf8能表示更多的字符。至于什么时候用,看你的做什么项目了,到http://blog.csdn.net/leelyliu/article/details/52879685看unicode编码区从1 ~ 126就属于传统utf8区,当然utf8mb4也兼容这个区,126行以下就是utf8mb4扩充区,什么时候你需要存储那些字符,你才用utf8mb4,否则只是浪费空间。

2.排序说明

mysql数据库管理-创建数据库

排序一般分为两种:utf_bin和utf_general_ci

bin 是二进制, a 和 A 会别区别对待.

例如你运行:

SELECT * FROM table WHERE txt = 'a'

那么在utf8_bin中你就找不到 txt = 'A' 的那一行, 而 utf8_general_ci 则可以.

utf8_general_ci 不区分大小写,这个你在注册用户名和邮箱的时候就要使用。

utf8_general_cs 区分大小写,如果用户名和邮箱用这个 就会照成不良后果

utf8_bin:字符串每个字符串用二进制数据编译存储。 区分大小写,而且可以存二进制的内容

utf8_unicode_ci和utf8_general_ci对中、英文来说没有实质的差别。

utf8_general_ci校对速度快,但准确度稍差。(准确度够用,一般建库选择这个)

utf8_unicode_ci准确度高,但校对速度稍慢。

另外,utf8_unicode_ci比较准确,utf8_general_ci速度比较快。如果有德语、法语或者俄语,请一定使用utf8_unicode_ci,通常情况下 utf8_general_ci的准确性就够我们用的了。