helios741 / myblog

觉得好请点小星星,欢迎有问题交流(issue/email)
109 stars 21 forks source link

mysql常用命令 #70

Open helios741 opened 4 years ago

helios741 commented 4 years ago

查看有多少连接

show processlist;
helios741 commented 4 years ago

查看建表语句

SHOW CREATE TABLE customer;
helios741 commented 4 years ago

修改表的默认字符集

ALTER TABLE 表名 DEFAULT CHARSET utf8;
helios741 commented 4 years ago

mysql插入中文报错

报下面的错误:

ysql> INSERT INTO compresspackagemodel VALUES (2, "中文", "2019-12-19 14:43:47", "2019-12-19 14:43:47", "又是中文");
ERROR 1366 (HY000): Incorrect string value: '\xE4\xB8\xAD\xE6\x96\x87' for column 'addr' at row 1

在peewee框架中报错如下:

peewee.InternalError: (1366, "Incorrect string value: ‘\\xF0\\x9F\\x90\\xA8’ for column ‘name’ at row 1
helios741 commented 4 years ago

修改字段类型:ALTER table yarn MODIFY COLUMN keytab varchar(10000) DEFAULT NULL;