我一直在寻找解决方案。最初尝试运行 mysql 时,我得到了:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
关于此问题有很多信息,但没有一个真正对我有帮助。
进一步挖掘后发现,问题似乎在于尝试加载时因超时而启动失败。
卸载 mariadb 并重新按照安装过程操作后,系统按预期运行... 直到重新启动服务器,然后什么都没有!套接字错误如上所述。我的想法是套接字错误是次要的,因为服务在重新启动后甚至没有运行。
重新启动服务之前,启动、停止、重新启动和重新加载命令可以正常工作。
我正在运行 UFW,没有为 MySQL 启用任何端口,但我尚未远程访问服务器,因此假设这不是问题 - 所有对数据库的访问都是/将是通过托管页面从本地文件系统进行的。
我正在运行最新的稳定版 Ubuntu,加密主目录,并使用 LAMP 选项进行安装。我卸载了我认为是 MySQL 的版本(但可能已经是 MariaDB),转而安装 MariaDB。现在出现了这些问题。在首次卸载之前,服务器是全新安装的 ubuntu(没有硬盘容量问题),而且我之前没有测试过 mysql,因此无法评论之前的错误。
我不知道下一步该调查哪里,所以很感激您的想法。
还要注意的是,根据一些建议,我似乎没有 mariadb*.log 或 mysql*.log 文件可以查询
service mariadb status
如下:
● mariadb.service - MariaDB 10.2.14 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: failed (Result: timeout) since Sat 2018-04-14 13:01:43 BST; 1min 28s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 1362 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 1074 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit
Process: 1061 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 1014 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 1362 (code=exited, status=0/SUCCESS)
CPU: 574ms
Apr 14 13:01:40 smcserver systemd[1]: mariadb.service: Start operation timed out. Terminating.
Apr 14 13:01:41 smcserver mysqld[1362]: 2018-04-14 13:01:41 139873867650816 [Note] InnoDB: Starting shutdown...
Apr 14 13:01:41 smcserver mysqld[1362]: 2018-04-14 13:01:41 139873151330048 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
Apr 14 13:01:41 smcserver mysqld[1362]: 2018-04-14 13:01:41 139873151330048 [Note] InnoDB: Buffer pool(s) dump completed at 180414 13:01:41
Apr 14 13:01:43 smcserver mysqld[1362]: 2018-04-14 13:01:43 139873867650816 [Note] InnoDB: Shutdown completed; log sequence number 1620137
Apr 14 13:01:43 smcserver mysqld[1362]: 2018-04-14 13:01:43 139873867650816 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
Apr 14 13:01:43 smcserver mysqld[1362]: 2018-04-14 13:01:43 139873867650816 [Note] /usr/sbin/mysqld: Shutdown complete
Apr 14 13:01:43 smcserver systemd[1]: Failed to start MariaDB 10.2.14 database server.
Apr 14 13:01:43 smcserver systemd[1]: mariadb.service: Unit entered failed state.
Apr 14 13:01:43 smcserver systemd[1]: mariadb.service: Failed with result 'timeout'.
这是我的journalctl -u mariadb.service
日志:
Apr 14 13:00:06 smcserver systemd[1]: Starting MariaDB 10.2.14 database server...
Apr 14 13:00:14 smcserver mysqld[1362]: 2018-04-14 13:00:14 139874051098816 [Note] /usr/sbin/mysqld (mysqld 10.2.14-MariaDB-10.2.14+maria~artful-log) starting as process 1362 ...
Apr 14 13:00:16 smcserver mysqld[1362]: 2018-04-14 13:00:16 139874051098816 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
Apr 14 13:00:16 smcserver mysqld[1362]: 2018-04-14 13:00:16 139874051098816 [Note] InnoDB: Uses event mutexes
Apr 14 13:00:16 smcserver mysqld[1362]: 2018-04-14 13:00:16 139874051098816 [Note] InnoDB: Compressed tables use zlib 1.2.11
Apr 14 13:00:16 smcserver mysqld[1362]: 2018-04-14 13:00:16 139874051098816 [Note] InnoDB: Using Linux native AIO
Apr 14 13:00:16 smcserver mysqld[1362]: 2018-04-14 13:00:16 139874051098816 [Note] InnoDB: Number of pools: 1
Apr 14 13:00:16 smcserver mysqld[1362]: 2018-04-14 13:00:16 139874051098816 [Note] InnoDB: Using generic crc32 instructions
Apr 14 13:00:16 smcserver mysqld[1362]: 2018-04-14 13:00:16 139874051098816 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
Apr 14 13:00:16 smcserver mysqld[1362]: 2018-04-14 13:00:16 139874051098816 [Note] InnoDB: Completed initialization of buffer pool
Apr 14 13:00:16 smcserver mysqld[1362]: 2018-04-14 13:00:16 139873311708928 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page
Apr 14 13:00:17 smcserver mysqld[1362]: 2018-04-14 13:00:17 139874051098816 [Note] InnoDB: Highest supported file format is Barracuda.
Apr 14 13:00:17 smcserver mysqld[1362]: 2018-04-14 13:00:17 139874051098816 [Note] InnoDB: 128 out of 128 rollback segments are active.
Apr 14 13:00:17 smcserver mysqld[1362]: 2018-04-14 13:00:17 139874051098816 [Note] InnoDB: Creating shared tablespace for temporary tables
Apr 14 13:00:17 smcserver mysqld[1362]: 2018-04-14 13:00:17 139874051098816 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
Apr 14 13:00:17 smcserver mysqld[1362]: 2018-04-14 13:00:17 139874051098816 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Apr 14 13:00:18 smcserver mysqld[1362]: 2018-04-14 13:00:18 139874051098816 [Note] InnoDB: 5.7.21 started; log sequence number 1620109
Apr 14 13:00:18 smcserver mysqld[1362]: 2018-04-14 13:00:18 139873151330048 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Apr 14 13:00:18 smcserver mysqld[1362]: 2018-04-14 13:00:18 139873151330048 [Note] InnoDB: Buffer pool(s) load completed at 180414 13:00:18
Apr 14 13:00:18 smcserver mysqld[1362]: 2018-04-14 13:00:18 139874051098816 [Note] Plugin 'FEEDBACK' is disabled.
Apr 14 13:00:18 smcserver mysqld[1362]: 2018-04-14 13:00:18 139874051098816 [Note] Server socket created on IP: '127.0.0.1'.
Apr 14 13:00:19 smcserver mysqld[1362]: 2018-04-14 13:00:19 139874051098816 [Note] Reading of all Master_info entries succeded
Apr 14 13:00:19 smcserver mysqld[1362]: 2018-04-14 13:00:19 139874051098816 [Note] Added new Master_info '' to hash table
Apr 14 13:00:19 smcserver mysqld[1362]: 2018-04-14 13:00:19 139874051098816 [Note] /usr/sbin/mysqld: ready for connections.
Apr 14 13:00:19 smcserver mysqld[1362]: Version: '10.2.14-MariaDB-10.2.14+maria~artful-log' socket: '/var/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
Apr 14 13:01:40 smcserver mysqld[1362]: 2018-04-14 13:01:40 139873867650816 [Note] /usr/sbin/mysqld (initiated by: unknown): Normal shutdown
Apr 14 13:01:40 smcserver mysqld[1362]: 2018-04-14 13:01:40 139873193293568 [Note] InnoDB: FTS optimize thread exiting.
Apr 14 13:01:40 smcserver mysqld[1362]: 2018-04-14 13:01:40 139873867650816 [Note] Event Scheduler: Purging the queue. 0 events
Apr 14 13:01:40 smcserver systemd[1]: mariadb.service: Start operation timed out. Terminating.
Apr 14 13:01:41 smcserver mysqld[1362]: 2018-04-14 13:01:41 139873867650816 [Note] InnoDB: Starting shutdown...
Apr 14 13:01:41 smcserver mysqld[1362]: 2018-04-14 13:01:41 139873151330048 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
Apr 14 13:01:41 smcserver mysqld[1362]: 2018-04-14 13:01:41 139873151330048 [Note] InnoDB: Buffer pool(s) dump completed at 180414 13:01:41
Apr 14 13:01:43 smcserver mysqld[1362]: 2018-04-14 13:01:43 139873867650816 [Note] InnoDB: Shutdown completed; log sequence number 1620137
Apr 14 13:01:43 smcserver mysqld[1362]: 2018-04-14 13:01:43 139873867650816 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
Apr 14 13:01:43 smcserver mysqld[1362]: 2018-04-14 13:01:43 139873867650816 [Note] /usr/sbin/mysqld: Shutdown complete
Apr 14 13:01:43 smcserver systemd[1]: Failed to start MariaDB 10.2.14 database server.
Apr 14 13:01:43 smcserver systemd[1]: mariadb.service: Unit entered failed state.
Apr 14 13:01:43 smcserver systemd[1]: mariadb.service: Failed with result 'timeout'.
答案1
系统上有多少 RAM,只要您在尝试启动 mysql 时使用 sudo,您也需要至少 1GB 的 RAM 来启动它。