Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何检查与 MySQL db 的连接没有死,并避免不必要地(关闭和)重新创建连接?说,我正在 Bash 脚本中创建和使用连接。
我所说的“死”是指,也许最后一次使用创建的连接是在 1 小时前,在服务器端,它可能会以某种方式杀死非活动连接。
检查的唯一方法是尝试使用它。
SELECT 1您可以在执行实际命令之前先发制人地执行基本命令。
SELECT 1