配置mysql配置文件
控制台执行命令 sudo vi /etc/mysql/my.cnf
1. 设置控制台默认编码,在 [client] 下面加入
default-character-set = utf8
2. 设置默认编码,在[mysqld]下面加入
default-character-set = utf8
3. 设置默认引擎,在[mysqld]下面加入
default-storage-engine = InnoDB
4. 忽略表名大小写,在[mysqld]下面加入
lower_case_table_names=1
5. 配置所有的外部用户对所有的数据库和表有操作权限
注释掉bind-address = 127.0.0.1
登录mysql执行,grant all privileges on *.* to 'root'@'%' identified by 'passwd' with grant option;
立即生效
flush privileges;
6. 创建数据库命令
CREATE DATABASE test001
CHARACTER SET gbk
DEFAULT CHARACTER SET gbk
COLLATE gbk_chinese_ci
DEFAULT COLLATE gbk_chinese_ci ;
---------------------------------------------
CREATE DATABASET test002
CHARACTER SET utf8
DEFAULT CHARACTER SET utf8
COLLATE utf8_general_ci
DEFAULT COLLATE utf8_general_ci ;