what do you mean with "statement traces"?
How to see mysql statement traces under ubuntu 22.04 ?
If there is a way to check/see mysql statement traces under ubuntu 22.04 ?
8.0.34-0ubuntu0.22.04.1
Thanks in advance!
@Tray2 I mean like log with statement traces
@PetroGromovo If you are looking for slow queries, I suggest that you use a tool like Telescope.
@Tray2 a) I mean not under laravel app, but under mysql itself. Yes if there is a way to catch slow queries - I need some tool to catch them
@PetroGromovo You can see slow queries in Telescope https://laravel.com/docs/10.x/telescope#query-watcher
You can enable query logging, or specifically, slow query logging, in MySQL or MariaDB in /etc/my.cnf
Have you tried that?
@Garet I found article https://docs.cpanel.net/knowledge-base/sql/how-to-enable-the-slow-query-log-in-mysql-or-mariadb/
and edited lines in /etc/mysql/mysql.cnf file:
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
slow_query_log = 1
slow-query_log_file = /var/log/mysql-slow.log
long_query_time = 2
I created file and added permissions to file.
But restarting mysql server I got errors :
# sudo systemctl restart mysql
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details.
# systemctl status mysql.service
× mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2024-02-03 07:12:52 EET; 8s ago
Process: 9264 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
CPU: 21ms
feb 03 07:12:52 hoster systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
feb 03 07:12:52 hoster systemd[1]: Stopped MySQL Community Server.
feb 03 07:12:52 hoster systemd[1]: mysql.service: Start request repeated too quickly.
feb 03 07:12:52 hoster systemd[1]: mysql.service: Failed with result 'exit-code'.
feb 03 07:12:52 hoster systemd[1]: Failed to start MySQL Community Server.
# journalctl -xeu mysql.service
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ An ExecStartPre= process belonging to unit mysql.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
feb 03 07:12:52 hoster systemd[1]: mysql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code'.
feb 03 07:12:52 hoster systemd[1]: Failed to start MySQL Community Server.
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit mysql.service has finished with a failure.
░░
░░ The job identifier is 3714 and the job result is failed.
feb 03 07:12:52 hoster systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ Automatic restarting of the unit mysql.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
feb 03 07:12:52 hoster systemd[1]: Stopped MySQL Community Server.
░░ Subject: A stop job for unit mysql.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit mysql.service has finished.
░░
░░ The job identifier is 3847 and the job result is done.
feb 03 07:12:52 hoster systemd[1]: mysql.service: Start request repeated too quickly.
feb 03 07:12:52 hoster systemd[1]: mysql.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit mysql.service has entered the 'failed' state with result 'exit-code'.
feb 03 07:12:52 hoster systemd[1]: Failed to start MySQL Community Server.
░░ Subject: A start job for unit mysql.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit mysql.service has finished with a failure.
░░
░░ The job identifier is 3847 and the job result is failed.
After I commented all new lines lines in /etc/mysql/mysql.cnf file - I restarted mysql server ok... What is wrong ?
@PetroGromovo Your configuration is invalid. The setting is slow_query_log_file. It's also not in the correct option group, but that's a minor point.
You already knew where the problem was since commenting out the lines fixed the issue. Why not double check those lines to see if you made a mistake? Or run systemctl status mysql.service as the error message suggested? Those would be my first two steps.
@JussiMannisto I read this https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html docs It has a lot parameters
I added in file:///etc/mysql/mysql.cnf lines :
slow_query_log = 1
long_query_time = 1
log_slow_rate_limit = 1000
log_slow_verbosity = query_plan
log-queries-not-using-indexes
slow_query_log_file = /var/log/mysql-slow.log
But restarting mysql server I got error:
# systemctl status mysql.service
× mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2024-02-03 14:40:31 EET; 2min 7s ago
Process: 27437 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
CPU: 22ms
feb 03 14:40:31 master-at-home systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
feb 03 14:40:31 master-at-home systemd[1]: Stopped MySQL Community Server.
feb 03 14:40:31 master-at-home systemd[1]: mysql.service: Start request repeated too quickly.
feb 03 14:40:31 master-at-home systemd[1]: mysql.service: Failed with result 'exit-code'.
feb 03 14:40:31 master-at-home systemd[1]: Failed to start MySQL Community Server.
Which is valid syntax of conf file ?
@PetroGromovo Again, that's invalid config. There's no setting called log-queries-not-using-indexes.
@JussiMannisto Commenting line with log-queries-not-using-indexes did not salve the error. Please give valid configuration. I searched in net - a lot of data including some old verions
@PetroGromovo You posted the manual from MySQL 8. That's all you need if you're indeed running MySQL 8.
Configuration isn't magic. You just need to use settings that are supported by your database. Twice now you've added settings with dashes where there should be underscores, so of course they're not going to work. And do you see a log_slow_rate_limit setting in the manual you posted?
You know why MySQL doesn't start. It's because you've entered invalid settings. So check those settings instead of asking other people to do it for you.
Please or to participate in this conversation.