MySQL

Mysql Slow Query

vi /etc/my.cnf

slow_query_log = 1
slow-query-log-file = /var/log/mysql-slow.log
long_query_time = 2

touch /var/log/mysql-slow.log

chown mysql:mysql /var/log/mysql-slow.log

systemctl restart mysqld

Connection Refused MySQL

https://chatgpt.com/share/67b548c2-8cc8-8013-ab45-89a4457eed65

1. sudo nano /etc/my.cnf
>     ensure bind address = 0.0.0.0 
>     sudo systemctl restart mysql

ensure # skip-networking is commented
ensure #block_encryption_mode and check ssl version compatible with the mysql version or not.

2.MySQL may block connections if require_secure_transport is enabled but the client isn't using SSL. (usually for staging server KPDN )
> Update my.cnf file require_secure_transport = OFF

Docker

```
$ docker run --name test-mysql -e MYSQL_ROOT_PASSWORD=strong_password -d mysql
```