我与Ubuntu 18.04
MySQL 5.7.24
和我试图使general_log
为described here。
所以在我的/etc/mysql/my.cnf
我加了这一点:
general_log = on
general_log_file=/tmp/mysql.log
然后我停止并再次启动MySQL,但是我得到一个错误:
$ sudo service mysql stop
$ sudo service mysql start
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" 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 Fri 2019-01-04 17:50:31 CET; 45s ago
Process: 27206 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
Process: 27613 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Main PID: 27208 (code=exited, status=0/SUCCESS)
Jan 04 17:50:31 librem systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 04 17:50:31 librem systemd[1]: Failed to start MySQL Community Server.
Jan 04 17:50:31 librem systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jan 04 17:50:31 librem systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Jan 04 17:50:31 librem systemd[1]: Stopped MySQL Community Server.
Jan 04 17:50:31 librem systemd[1]: mysql.service: Start request repeated too quickly.
Jan 04 17:50:31 librem systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 04 17:50:31 librem systemd[1]: Failed to start MySQL Community Server.
在journalctl -xe
我得到几乎相同。
我试图创造/tmp/mysql.log
日志文件和chmodding它777
,但这样做,启动MySQL后,失败同样的错误。
有谁知道什么是错在这里?
最后我解决它使用this tip。只是复制粘贴在这里它未来的读者:
SET global log_output = 'FILE';
SET global general_log_file='/var/log/mysql/general.log';
SET global general_log = 1;
无需重新启动。用户确实需要SUPER权限(GRANT SUPER ON *.* TO user1@localhost
)。这适用于在DB现有的和新的连接,是一个全球性的设置,以便它适用于所有数据库。
它可以被关闭
SET global general_log = 0;
在任何情况下,我祝大家美好的一天!