首页 文章

无法登录mariadb上工作

提问于
浏览
0

我正在尝试启用mariadb中的常规日志记录,以便我可以看到针对我的数据库生成的所有查询 .

我在ubuntu上运行5.5版:

MariaDB [(none)]> show variables like '%Version';
+------------------+---------------------------------+
| Variable_name    | Value                           |
+------------------+---------------------------------+
| innodb_version   | 5.5.43-MariaDB-37.2             |
| protocol_version | 10                              |
| version          | 5.5.44-MariaDB-1ubuntu0.14.04.1 |
+------------------+---------------------------------+
3 rows in set (0.03 sec)

MariaDB [(none)]>

在我的my.cnf文件中,这是我在[mysqld]部分中尝试添加的内容:

general-log
general-log-file=queries.log
log-output=file

我在使用的参考资料可以在这里找到:https://mariadb.com/kb/en/mariadb/general-query-log/

当我使用“/etc/init.d/mysql restart”重新启动我的数据库,并且我开始通过我的Web应用程序请求页面时,虽然我确定正在查询数据库,但我找不到正在生成的任何日志文件 .

有什么建议?

EDIT 1

仔细检查后,我注意到错误日志也不起作用 . 当我重新启动mysql时,我收到以下消息:

myuser@dev:/etc/mysql$ sudo /etc/init.d/mysql restart
 * Stopping MariaDB database server mysqld                                                                                       [fail] 
 * Starting MariaDB database server mysqld                                                                                       [ OK ]

注意stop命令是如何失败的 . 但我找不到任何错误日志 . 这是我在my.cnf中的整个msqld部分:

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
#
# * Fine Tuning
#
key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
general-log
general-log-file=queries.log
log-output=file
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#log_slow_queries       = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size         = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

EDIT 2

"show variables like '%log%'"命令的结果粘贴在此处:http://pastebin.com/Zt8xFxLN

第18行似乎是我的问题,可能是第30行的错误日志?如果我通过命令行更改这些值,它只会持续当前会话吗?

2 回答

  • -1

    我在mysql命令行上运行了以下命令:

    set global log="on"
    
  • 0

    在阅读第一个链接中的文档时,有些东西突出了我:

    通过将此添加到my.cnf文件中,所有查询都将记录到datadir目录中的query.log文件中 .

    所以,我启用它并查看了/ var / lib / mysql(mysql / mariadb datadir)的内容 .

    它就是 - queries.log

    datadir也不是我所期望的那样,但文档说的是这样 . 我宁愿在/ var / log / mysql中看到它(毕竟它是一个日志),所以我将上面的配置更改为完整路径(/var/log/mysql/queries.log) . 结果如预期的那样,日志最终在/ var / log / mysql中

    好极了!

相关问题