MySQL 连接数设置操作(Too many connections)及设置md5值的加密密码
mysql在使用过程中,发现连接数超了~~~~
[root@linux-node1 ~]# mysql -u glance -h 192.168.1.17 -p
Enter password:
ERROR 1040 (08004): Too many connections
解决办法,这也是centos7下修改mysql连接数的做法:
1)临时修改
MariaDB [(none)]> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
1 row in set (0.00 sec)
MariaDB [(none)]> set GLOBAL max_connections=1000;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
1 row in set (0.00 sec)
2)永久修改:
配置/etc/my.cnf
[mysqld]新添加一行如下参数:
max_connections=1000
重启mariadb服务,再次查看mariadb数据库最大连接数,可以看到最大连接数是214,并非我们设置的1000。
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 214 |
+-----------------+-------+
这是由于mariadb有默认打开文件数限制。可以通过配置/usr/lib/systemd/system/mariadb.service来调大打开文件数目。
配置/usr/lib/systemd/system/mariadb.service
[Service]新添加两行如下参数:
LimitNOFILE=10000
LimitNPROC=10000
重新加载系统服务,并重启mariadb服务
systemctl --system daemon-reload
systemctl restart mariadb.service
再次查看mariadb数据库最大连接数,可以看到最大连接数已经是1000
MariaDB [(none)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 1000 |
+-----------------+-------+
=============================================================================
mysql设置32位md5值的密文密码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 如下,设置admin用户的密码为 "123!@#ad" mysql> select * from admin_user; +----+----------+--------------------------------------------------------------------+----------------------+---------------------+ | id | username | password | create_time | update_time | +----+---------------+---------------------------------------------------------------+----------------------+---------------------+ | 1 | admin | 4ad597c11755c50d00457f4420365763 | 1538979880 | 1538979880 | +----+---------------+---------------------------------------------------------------+----------------------+---------------------+ 1 row in set (0.00 sec) mysql> update admin_user set username = 'admin' ,password = md5( '123!@#ad' ) where id = 1 mysql> select * from admin_user; +----+----------+--------------------------------------------------------------------+----------------------+---------------------+ | id | username | password | create_time | update_time | +----+---------------+---------------------------------------------------------------+----------------------+---------------------+ | 1 | admin | 0fy866r8662a70d85632u90563212687 | 1541676212 | 1541676212 | +----+---------------+---------------------------------------------------------------+----------------------+---------------------+ 1 row in set (0.00 sec) |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南