MySQL
Commands
Run as a Docker container
docker run --name mysql -p 3306:3306 -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:8
Connection
mysql -u username -p password -h hostname
SQL
Getting primary key from table
SHOW KEYS FROM TABLE;
Check the process
SHOW PROCESSLIST;
Check the max_connections
SHOW VARIABLES LIKE 'max_connections';
output:
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 150 |
+-----------------+-------+
Checking the wait_timeout
SHOW VARIABLES LIKE '%timeout%';
To show the comments from the table
SHOW FULL COLUMNS FROM TABLE;
JSON
JSON_ARRAY will return a JSON array
mysql> SELECT JSON_ARRAY(1, "abc", NULL, TRUE, CURTIME());
+---------------------------------------------+
| JSON_ARRAY(1, "abc", NULL, TRUE, CURTIME()) |
+---------------------------------------------+
| [1, "abc", null, true, "11:30:24.000000"] |
+---------------------------------------------+
Troubleshooting
mysqldump --skip-lock-tables --set-gtid-purged=OFF ......