8篇 mysql 相关的文章

就在刚刚,又被面试官的mysql联合索引问题问倒了

MySql经常用,但是通常就是ORM中间件来CRUD操作,很少关注索引问题,可能是我近些年很少用MySQL做大型的系统了。
现在一面试就遇到所有领域的问题来都来一个问一遍,MySQL的复合索引其实也就一知半解。

面试官的问类似于select语句里where a>100 and b=3 and c=1 能否命中创建的(a, b, c)这种索引,还有a>100能否命中这个复合索引。

我想当然就说,a>100 and b=3 and c=1 只能命令(a, b, c)这种索引, a>100不能命中。唉呀,人家笑了。我说我可能说的不对,我下来试试。好吧查资料,建表,亲自实操一把。

查看更多 ~

mysql delete foreign key

Check what's the CONSTRAINT name and the FOREIGN KEY name:

SHOW CREATE TABLE table_name;

Remove both the CONSTRAINT name and the FOREIGN KEY name:

ALTER TABLE table_name
  DROP FOREIGN KEY the_name_after_CONSTRAINT,
  DROP KEY the_name_after_FOREIGN_KEY;

Or simply run this if you know the foreign key name:

alter table footable drop foreign key fooconstraint

原文:https://stackoverflow.com/questions/838354/mysql-removing-some-foreign-keys

查看更多 ~

ld: library not found for -lssl - Install mysqlclient for Django 2, macos

Background

mysql server was installed by brew install mysql

Issues like this:

ERROR: Failed building wheel for mysqlclient

ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1

Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?

查看更多 ~

MySQL的主从配置

主从配置常用作考虑在主服务器上做读写操作,从服务器相当于备用节点。但也有主服务只写,slave只读这种达到读写分离。如果有多个从服务器,那其实每个从服务器可以单独来读,如数据分析、远程调用等而不暴露主库。

记得面试时问我MySQL的主从是怎样的,虽然使用过MySQL,但都是单机部署经验,随口一说结果被面试官问住了,回头亲自实践了下作个记录。

查看更多 ~