不会的要多查多问,不然不会的永远不会,哪怕你离会就差了那么一点点
[MySQL] 注意MySQL5.1不支持utf8mb4 Error 1115: Unknown character set: 'utf8mb4'
[ 2023/02/23 08:48 | by 刘新修 ]
MYSQL5.5支持utf8mb4,MYSQL5.1并不支持“utf8mb4”。
当连接数据库时 , 如果指定了utf8mb4 , 那么会出现的错误代码为:
Error 1115: Unknown character set: 'utf8mb4'
会出现utf8mb4不兼容的情况。
所以如果想使用utf8mb4存储表情emoji字符 , 请尽快升级
mysql 常用SQL汇总
[ 2016/09/07 15:17 | by 刘新修 ]
SQL代码
- 1.用管理员登陆
- mysql -u root -p;
- 2.创建数据库
- create database nodeDB;
- 3.删除数据库
- drop database nodeDB;
- 4.查看数据库
- show databases;
- 5.选择目标库
- use nodeDB;
- 6.查看目标表所有字段
- select * from user;
- 7.创建用户
- //user01只能本地访问
- CREATE USER user01@'localhost' IDENTIFIED BY 'user01';
- //user02可以远程访问
- CREATE USER user02@'%' IDENTIFIED BY 'password1';
- 8.修改user01密码
- SET PASSWORD FOR 'user01'@'localhost'=PASSWORD('password2');
- 9.授权
- //user01管理db01全部权限
- GRANT ALL PRIVILEGES ON nodeDB.* TO user01;
- //user02查看权限,并修改密码
- GRANT SELECT ON *.* TO 'user02'@'%' IDENTIFIED by 'password2';
- 10. 刷新数据库
- flush privileges;
创建测试表:
SQL代码
- //判断有库就删除
- drop database if exists school;
- create database school;
- use school;
- create table teacher(
- id int(3) auto_increment not null primary key,
- name char(10) not null,
- address varchar(50) default '深圳',
- year date
- );
- //以下为插入字段
- insert into teacher values(null,'allen','大连一中','1976-10-10');
- insert into teacher values(null,'jack','黄冈中学','1975-12-23');
- insert into teacher values(null,'jesse','北京四中','1980-6-23');
- insert into teacher values(null,'tony','衡水中学','1982-2-12');