使用命令lsof
即可。
如 lsof -i :3306
lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 773 hijack 32u IPv4 0x5273dd7b96798a1 0t0 TCP localhost:mysql (LISTEN)
也可以指定tcp 如lsof -i tcp:3306
8篇 mysql related articles
使用命令lsof
即可。
如 lsof -i :3306
lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 773 hijack 32u IPv4 0x5273dd7b96798a1 0t0 TCP localhost:mysql (LISTEN)
也可以指定tcp 如lsof -i tcp:3306
cat /proc/sys/kernel/random/uuid
#!/usr/bin/python
import uuid
print uuid.uuid1()
print uuid.uuid4()
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不能命中。唉呀,人家笑了。我说我可能说的不对,我下来试试。好吧查资料,建表,亲自实操一把。
ysql> SET foreign_key_checks = 0;
mysql> drop table photologue_gallery;
mysql> drop table photologue_photo;
mysql> SET foreign_key_checks = 1;
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
mysql server was installed by brew install mysql
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 ?
主从配置常用作考虑在主服务器上做读写操作,从服务器相当于备用节点。但也有主服务只写,slave只读这种达到读写分离。如果有多个从服务器,那其实每个从服务器可以单独来读,如数据分析、远程调用等而不暴露主库。
记得面试时问我MySQL的主从是怎样的,虽然使用过MySQL,但都是单机部署经验,随口一说结果被面试官问住了,回头亲自实践了下作个记录。
在Mac上通过brew安装Mysql后跑想进入数据库报这个
mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
手动启服务 ** mysql.server start ** 报这个
Starting MySQL
...... ERROR! The server quit without updating PID file (/usr/local/var/mysql/pcname.local.pid).