Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从shell脚本执行时关闭mysql连接_Mysql_Bash_Shell_Database Performance - Fatal编程技术网

从shell脚本执行时关闭mysql连接

从shell脚本执行时关闭mysql连接,mysql,bash,shell,database-performance,Mysql,Bash,Shell,Database Performance,使用shell脚本运行mysql insert查询,在运行查询时,我看到shell脚本没有关闭连接 运行shell脚本后的服务器响应 #!bin/bash query="insert into table_name values ('foo', 'bar' , 123, NOW() )where column_name is NOT NUll" mysql -u username -p password mysql <<EOF $query; EOF 26次以上的计数是什么样的

使用shell脚本运行mysql insert查询,在运行查询时,我看到shell脚本没有关闭连接

运行shell脚本后的服务器响应

#!bin/bash
query="insert into table_name values ('foo', 'bar' , 123, NOW() )where column_name is NOT NUll"

mysql -u username -p password mysql  <<EOF
$query;
EOF
26次以上的计数是什么样的

其中超过50个计数类似于(TIME_WAIT-22)和(stated-28)

  • 通过shell脚本运行的mysql连接是否自行关闭
  • 如果每30分钟通过cron作业运行一次带有mysql insert命令的shell脚本,会有什么更大的影响
  • 脚本

    #!bin/bash
    query="insert into table_name values ('foo', 'bar' , 123, NOW() )where column_name is NOT NUll"
    
    mysql -u username -p password mysql  <<EOF
    $query;
    EOF
    
    #!bin/bash
    query=“插入到列名称不为空的表名称值('foo','bar',123,NOW())
    
    mysql-u username-p password mysql什么
    状态
    值对应于建立的
    连接

    它的价值是什么

    `SHOW GLOBAL STATUS LIKE 'Max_used_connections';
    
    我期望一个像1或2这样的小数字

    为了

    我预计超过100人

    命令行工具mysql将创建一个连接(颠簸
    连接
    并可能增加
    最大已用连接
    的“高水位线”),执行该操作,然后关闭连接(不降低任何
    状态
    )<代码>正在运行的线程
    也会递增和递减


    cron作业不应威胁任何限制。

    变量名在bash中区分大小写。将
    $query
    更改为
    $query
    。以我的拙见,bash脚本一完成,即几分之一秒,连接就会关闭。您到底想实现什么?你不能先在你的系统上用
    select
    或模拟数据试试吗?@pierrefrancois刚刚更新了问题的更多细节,希望这有助于理解问题对不起,我以为你说的是与数据库的连接,即会话。
    #!bin/bash
    query="insert into table_name values ('foo', 'bar' , 123, NOW() )where column_name is NOT NUll"
    
    mysql -u username -p password mysql  <<EOF
    $query;
    EOF
    
    `SHOW GLOBAL STATUS LIKE 'Max_used_connections';
    
    `SHOW GLOBAL STATUS LIKE 'Connections';