MySQL

Slow query - MySQL

What is slow query? https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html The definition “slow query” is “SQL statements that take more than long_query_time seconds to execute and require at least min_examined_row_limit rows to be examined”. Configure Check current status SHOW VARIABLES LIKE "slow_query_log"; SHOW VARIABLES LIKE "slow_query_time"; SHOW VARIABLES LIKE "slow_query_log_file"; Enable to log slow queries Logging slow queries which take more than 10 seconds. SET GLOBAL slow_query_log = 'ON'; SET GLOBAL long_query_time = 10; SET GLOBAL slow_query_log_file = '/path/filename'; A sample line in the log file:

MySQL - Intro

This is a draft page. Connect to MySQL Open your terminal and execute the following. mysql -u root -p mysql: Connect to MySQL. -u root: as user root. -p : with the password. This command prompt you to input the password. After input your password, MySQL prmpt mysql> will appear. Make a normal user Create normal user There are users im MySQL, different from OS user. I recommend to make a new simple user in order to access control.

Install MySQL on macOS

Install Install MySQL in macOS with the installer Use official installer. MySQL - Official Download page: https://dev.mysql.com/downloads/mysql/ Initial password of the root user The root means the MySQL root user, not your macOS You should take a memo your password of root user (not Linux system super user.) For CLI After running installer, add the PATH to ~/.zshrc (or your shell. Check with $echo SHELL). alias mysql=/usr/local/mysql/bin/mysql alias mysqladmin=/usr/local/mysql/bin/mysqladmin Check the version mysql --version /usr/local/mysql/bin/mysql Ver 8.