MySQL 教程 在线

2769MySQL导入报错

MySQL导入报错

syntax to use near ‘json DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET

MySQL导入报错:

check the manual that corresponds to your MySQL server version for the right syntax to use near ‘json DEFAULT NULL,PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4’ at line 3

原因MySQL版本从5.7版本之后开始支持JSON数据类型sql包从较高版本导出后在将其导入较低版本 从5.7版本导出 然后导入5.6版本

解决方法方法一 将mysql升级到5.7及以上版本升

方法二 将sql文件中的json全部替换成longtext重新导入即可

2766MySQL 常见问题

0.0.0.0:3306: bind: address already in use

docker启动mysql报错

Error starting userland proxy: listen tcp4 0.0.0.0:3306: bind: address already in use

问题描述

Error response from daemon: driver failed programming external connectivity on endpoint mysql (11c5baee97c46d1f911f0ab48f5ee59b918dd27954102d40177997cba255962f): Error starting userland proxy: listen tcp4 0.0.0.0:3306: bind: address already in use

linux的3306端口被占用了

解决方法

查看当前占用端口 netstat -tanlp

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    

tcp        0      0 0.0.0.0:3306           0.0.0.0:*               LISTEN       13252/docker-proxy  

杀死进程 kill 13252 占用端口进程的

kill 13252

就可以成功启动docker的mysql镜像了

2757MySQL-this is incompatible with sql_mode=only_full_group_by

MySQL-this is incompatible with sql_mode=only_full_group_by

原理在mysql 5.7 版本及以上版本,默认sql配置 sql_mode="ONLY_FULL_GROUP_BY"

严格执行 "SQL92标准",为了尽量兼容程序 可调整 sql_mode 使其保持跟5.6一致

在sql执行时出现该原因:输出的结果是叫 target list就是select后面跟着的字段

还有group by column 是group by后面跟着的字段,由于开启了ONLY_FULL_GROUP_BY 所以如果字段没有在target list 和group by字段中同时出现或聚合函数的值,那么这条sql被mysql认为非法 错误

查看sql_mode的语句

select @@GLOBAL.sql_mode;

解决方案 推荐解决方案 完美解决

修改mysql配置文件 添加sql_mode方式强制指定不需要ONLY_FULL_GROUP_BY属性

etc文件夹下 my.cnf 光标移到最后,添加

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

重启mysql服务,顺利解决

2737HeidiSQL

HeidiSQL

What's this?

HeidiSQL is free software, and has the aim to be easy to learn.

"Heidi" lets you see and edit data and structures from computers running one of the database systems

MariaDB, MySQL, Microsoft SQL, PostgreSQL and SQLite.

Invented in 2002 by Ansgar,

HeidiSQL belongs to the most popular tools for MariaDB and MySQL worldwide.

Download HeidiSQL, read further about features, take part in discussions or see some screenshots

open source

heidisql.com/download.php

2694MYSQL时间字段INT,TIMESTAMP,DATETIME性能效率

MYSQL时间字段INT,TIMESTAMP,DATETIME性能效率

对于MyISAM引擎 采用 UNIX_TIMESTAMP(timestamp) 比较 效率高

对于InnoDB引擎 建立索引 采用 int 或 datetime直接时间比较效率高