- 論壇徽章:
- 0
|
增加一個(gè)管理員帳戶:grant all on *.* to user@localhost identified by "password";
查詢(xún)時(shí)間:select now();
查詢(xún)當(dāng)前用戶:select user();
查詢(xún)數(shù)據(jù)庫(kù)版本:select version();
查詢(xún)當(dāng)前使用的數(shù)據(jù)庫(kù):select database();
列出數(shù)據(jù)庫(kù):show databases;
選擇數(shù)據(jù)庫(kù):use databaseName;
列出表格:show tables;
增加一個(gè)管理員帳戶:grant all on *.* to user@localhost identified by "password";
或授權(quán)一個(gè)新用戶:
grant select,insert,update,delete on *.* to user@localhost Identified by "123";
如果是遠(yuǎn)程用戶:
localhost改為% 或者"%"
更改表的字符集:
mysql> alter table users character set GBK;
這時(shí)向表中插入中文然后有錯(cuò)誤。
mysql> insert into users values(88,'中文');
ERROR 1366 (HY000): Incorrect string value: '\xD6\xD0\xCE\xC4' for column 'usern
ame' at row 1
mysql> insert into users values(88,'中文');
ERROR 1366 (HY000): Incorrect string value: '\xD6\xD0\xCE\xC4' for column 'usern
ame' at row 1
還要更改users表的username的字符集。
mysql> alter table users modify username char(20) character set gbk;
ERROR 1366 (HY000): Incorrect string value: '\xC0\xEE\xCB\xC4' for column 'usern
ame' at row 1
mysql> alter table users modify username char(20) character set gbk;
ERROR 1366 (HY000): Incorrect string value: '\xC0\xEE\xCB\xC4' for column 'usern
ame' at row 1
因?yàn)楸碇幸呀?jīng)有數(shù)據(jù),所以更改username字符集的操作沒(méi)有成***
清空users表中的數(shù)據(jù)
mysql> truncate table users;
Query OK, 3 rows affected (0.01 sec)
從新更改user表中username的字符集
mysql> alter table users modify username char(20) character set gbk;
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0
這時(shí)再插入中文字符,插入成***。
mysql> insert into users values(88,'中文');
Query OK, 1 row affected (0.01 sec)
mysql> select * from users;
+--------+----------+
| userid | username |
+--------+----------+
| 88 | 中文 |
+--------+----------+
1 row in set (0.00 sec)
mysql>
本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u3/103679/showart_2166756.html |
|