Linux登陆Mariadb数据库,MariaDB的线程及连接

今天在这里介绍一下确认mariaDB(和MySQL一样)的链接数及线程数的方法。MariaDB和MySQL有什么不一样,现在还没有弄清楚。

这是减少数据库的负载,并能提高数据库运行效率的入门。

连接mariaDB

# mysql -uroot -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 1176

Server version: 5.5.41-MariaDB-log MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

最大连接数

MariaDB [(none)]> show global variables like 'max_connections';

+-----------------+-------+

| Variable_name | Value |

+-----------------+-------+

| max_connections | 151 |

+-----------------+-------+

1 row in set (0.00 sec)

MariaDB启动后的累计连接数

MariaDB [(none)]> show global status like 'Connections';

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| Connections | 1190 |

+---------------+-------+

1 row in set (0.00 sec)

mariaDB启动后的最大同时连接数

MariaDB [(none)]> show global status like 'Max_used_connections';

+----------------------+-------+

| Variable_name | Value |

+----------------------+-------+

| Max_used_connections | 7 |

+----------------------+-------+

1 row in set (0.00 sec)

MariaDB线程信息

MariaDB [(none)]> show global status like 'Thread_%';

+-------------------------+-------+

| Variable_name | Value |

+-------------------------+-------+

| Threadpool_idle_threads | 0 |

| Threadpool_threads | 0 |

| Threads_cached | 6 |

| Threads_connected | 1 |

| Threads_created | 7 |

| Threads_running | 1 |

+-------------------------+-------+

6 rows in set (0.01 sec)

Threads_cached:备用的线程数(线程是可以再利用的)

Threads_connected:现在的连接数

Threads_created:备用的线程不足时,会生成新线程(这个值不断变大时,表示Threads_cached不足)

Threads_running:正在执行中的线程,也可以说是不在Sleep状态的线程

Threads_cached + Threads_connected < thread_cache_size是理想的状态。

MariaDB [(none)]> show global variables like ‘thread_cache_size’;

+——————-+——-+

| Variable_name | Value |

+——————-+——-+

| thread_cache_size | 52 |

+——————-+——-+

1 row in set (0.00 sec)

小结

从以上也可以看出来,在MySQL上使用的命令基本上也可以在MariaDB使用。

最重要的是,MySQL逻辑和MariaDB逻辑还看不出有什么不一样,看出不同可能需要更深入的使用MariaDB。

MariaDB 的详细介绍:请点这里

MariaDB 的下载地址:请点这里

0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值