mysql集锦

December 25, 2019
mysql

1 mysql 8新建root用户

可以远程访问的那种:

(1)新建用户

CREATE USER ‘root’@‘%’ IDENTIFIED BY ‘password’;

(2)授权

grant all on dbname.* to ‘root’@‘%’;

(3)生效

flush privileges;

2 mysql端口无法远程连接

报错:Host ‘172.26.71.240’ is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’

通过命令查看连接数:mysqladmin -uroot status,结果如下:

Uptime: 767033  Threads: 12  Questions: 430422  Slow queries: 0  Opens: 582  Flush tables: 4  Open tables: 396  Queries per second avg: 0.561

其中Treads就是连接线程。或者登录mysql,使用命令:show full processlist,查出连接的详情。

查一下连接数的配置show variables like '%max_connections%',明明就是:

+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| max_connections        | 151   |
| mysqlx_max_connections | 100   |
+------------------------+-------+

怎么会无法建立连接呢?


loading