我与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
中创建日志文件并将其更改为777
,但是这样做之后,启动mysql失败并出现相同的错误。
有人知道这是怎么回事吗?
答案 0 :(得分:0)
最后,我使用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
)。这适用于数据库上的现有和新连接,并且是全局设置,因此适用于所有数据库。
可以用
关闭SET global general_log = 0;
无论如何,祝您美好的一天!