MySQL general_log 无法启用。我究竟做错了什么?
MySQL general_log cannot be enabled. What am I doing wrong?
我在 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 失败并出现相同的错误。
有人知道这里出了什么问题吗?
最后我用this tip解决了。只需将其复制粘贴到此处以供将来的读者使用:
SET global log_output = 'FILE';
SET global general_log_file='/var/log/mysql/general.log';
SET global general_log = 1;
无需重启。用户确实需要超级权限 (GRANT SUPER ON *.* TO user1@localhost
)。这适用于数据库上的现有连接和新连接,并且是全局设置,因此适用于所有数据库。
可以用
关闭
SET global general_log = 0;
无论如何,祝大家有个美好的一天!
我在 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 失败并出现相同的错误。
有人知道这里出了什么问题吗?
最后我用this tip解决了。只需将其复制粘贴到此处以供将来的读者使用:
SET global log_output = 'FILE';
SET global general_log_file='/var/log/mysql/general.log';
SET global general_log = 1;
无需重启。用户确实需要超级权限 (GRANT SUPER ON *.* TO user1@localhost
)。这适用于数据库上的现有连接和新连接,并且是全局设置,因此适用于所有数据库。
可以用
关闭SET global general_log = 0;
无论如何,祝大家有个美好的一天!