Chinaunix

标题: 求助关于MYSQL取值。。 [打印本页]

作者: Ancilla820    时间: 2013-08-14 10:46
标题: 求助关于MYSQL取值。。
现在的问题是这样 我想要取show variables like 'max_connections';的value值,但这条语句显示出来的是个列表,像这样
  1. +-----------------+-------+
  2. | Variable_name   | Value |
  3. +-----------------+-------+
  4. | max_connections | 151   |
  5. +-----------------+-------+
复制代码
我只想让它显示VALUE的值也就是151。。。有办法能实现吗?
作者: RogerZhuo    时间: 2013-08-14 11:39
1、直接从I_S.GLOBAL_VARIABLES来取
[root@DB mysql]# mysql -uroot  --protocol=tcp -N -e  " select  VARIABLE_VALUE from information_schema.GLOBAL_VARIABLES where VARIABLE_NAME='max_connections'"
+------+
| 1000 |
+------+

2、也可以通过Shell来切割一下

11.jpg (16.24 KB, 下载次数: 50)

11.jpg

作者: bikong0411    时间: 2013-08-15 08:40
回复 2# RogerZhuo


    学习了
作者: seesea2517    时间: 2013-08-15 10:03
回复 2# RogerZhuo


    学习了~
作者: 飞鸿无痕    时间: 2013-08-16 00:07
本帖最后由 飞鸿无痕 于 2013-08-16 00:08 编辑

接2楼兄弟的,再加个-ss取消掉表格显示。
mysql -uroot   -ss -e  " select  VARIABLE_VALUE from information_schema.GLOBAL_VARIABLES where VARIABLE_NAME='max_connections'"





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2