1 -- 查看系統用戶 2 select Host,User,Password from mysql.user; 3 4 -- 創建一個遠程用戶 5 create user test identified by '123456'; 6 7 -- 分配權限 8 grant all privileges on *.* to 'test'@'%'identified by '123456' with grant option; 9 10 -- 刷新mysql用戶權限 11 flush privileges ; 12 13 -- 修改指定用戶密碼 14 update mysql.user set password=password('新密碼') where User="test" and Host="localhost"; 15 16 -- 刪除用戶 17 delete from user where User='test' and Host='localhost';
-- 查看mysql支持字符集 show variables like "% character %";
-- 建立數據庫並指定編碼 create database app_relation character set utf8; -- 修改數據庫編碼 alter database app_relation character set utf8;
CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE DATABASE 的語法:
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
[create_specification [, create_specification] ...]
create_specification:
[DEFAULT] CHARACTER SET charset_name
| [DEFAULT] COLLATE collation_name
更改數據庫的字符編碼
ALTER DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci