Manjaro部署Nextcloud时MariaDB连接失败问题求助
背景
我是家庭服务器(甚至Linux)新手,正在尝试搭建并运行Nextcloud。我使用的是Linux 6.1.0-1 Manjaro(基于Arch Linux),主要通过SSH访问。我正一步步遵循Arch Wiki上的Nextcloud指南操作。
报错前的操作
我成功遵循上述指南操作到4.4 MariaDB/MySQL部分:
- 使用
sudo pacman -S mariadb安装了mariadb,然后使用mariadb-install-db命令初始化。提示显示已成功初始化,有两个用户数据库(术语可能有误),分别名为root和arash(我的用户名)。 - 按照指南修改了
/etc/my.cnf.d/server.cnf,当前该文件内容如下:
# # These groups are read by MariaDB server. # Use it for options that only the server (but not clients) should see # # See the examples of server my.cnf files in /usr/share/mysql/ # # this is read by the standalone daemon and embedded servers [server] # this is only for the mysqld standalone daemon [mysqld] skip_networking transaction_isolation=READ-COMMITTED # # * Galera-related settings # [galera] # Mandatory settings #wsrep_on=ON #wsrep_provider= #wsrep_cluster_address= #binlog_format=row #default_storage_engine=InnoDB #innodb_autoinc_lock_mode=2 # # Allow server to accept connections on all interfaces. # #bind-address=0.0.0.0 # # Optional setting #wsrep_slave_threads=1 #innodb_flush_log_at_trx_commit=0 # this is only for embedded server [embedded] # This group is only read by MariaDB servers, not by MySQL. # If you use the same .cnf file for MySQL and MariaDB, # you can put MariaDB-only options here [mariadb] # This group is only read by MariaDB-10.8 servers. # If you use the same .cnf file for MariaDB of different versions, # use this group for options that older servers don't understand [mariadb-10.8]
报错信息
接下来的步骤是连接root数据库($ mysql -u root -p),出现以下错误:
$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)
已尝试的解决方法
- 尝试用
systemctl启动服务,服务可enable但无法start:
$ sudo systemctl start mysql [sudo] password for arash: Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xeu mariadb.service" for details.
systemctl status mariadb的输出:
$ sudo systemctl status mariadb [sudo] password for arash: × mariadb.service - MariaDB 10.9.4 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled) Active: failed (Result: exit-code) since Sun 2022-12-18 05:30:18 +0330; 5min ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Process: 8740 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 8741 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recov> Process: 8776 ExecStart=/usr/bin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILUR> Main PID: 8776 (code=exited, status=1/FAILURE) Status: "MariaDB server is down" CPU: 329ms Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_b> Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [Note] InnoDB: Buffer pool(s) load completed at 221218 5:30:18 Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugi> Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.ser> Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [ERROR] Fatal error: Can't open and lock privilege tables: Tab> Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [ERROR] Aborting Dec 18 05:30:18 opti780-Server mariadbd[8776]: Warning: Memory not freed: 280 Dec 18 05:30:18 opti780-Server systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE Dec 18 05:30:18 opti780-Server systemd[1]: mariadb.service: Failed with result 'exit-code'. Dec 18 05:30:18 opti780-Server systemd[1]: Failed to start MariaDB 10.9.4 database server. ...skipping... × mariadb.service - MariaDB 10.9.4 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: disabled) Active: failed (Result: exit-code) since Sun 2022-12-18 05:30:18 +0330; 5min ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Process: 8740 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 8741 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recov> Process: 8776 ExecStart=/usr/bin/mariadbd $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILUR> Main PID: 8776 (code=exited, status=1/FAILURE) Status: "MariaDB server is down" CPU: 329ms Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_b> Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [Note] InnoDB: Buffer pool(s) load completed at 221218 5:30:18 Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugi> Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.ser> Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [ERROR] Fatal error: Can't open and lock privilege tables: Tab> Dec 18 05:30:18 opti780-Server mariadbd[8776]: 2022-12-18 5:30:18 0 [ERROR] Aborting Dec 18 05:30:18 opti780-Server mariadbd[8776]: Warning: Memory not freed: 280 Dec 18 05:30:18 opti780-Server systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE Dec 18 05:30:18 opti780-Server systemd[1]: mariadb.service: Failed with result 'exit-code'. Dec 18 05:30:18 opti780-Server systemd[1]: Failed to start MariaDB 10.9.4 database server. ~ ~ ~
- 取消
/etc/my.cnf.d/server.cnf中的bind-address=0.0.0.0注释,无变化。 - 卸载并重新安装MariaDB:
pacman -R mariadb pacman -S mariadb
- 使用替代命令初始化和启动守护进程:
mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
结果:问题依然存在
ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (111)
- 尝试启动命令:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'
结果:问题依然存在
221218 06:59:04 mysqld_safe Logging to '/var/lib/mysql/opti780-Server.err'. 221218 06:59:04 mysqld_safe Starting mariadbd daemon with databases from /var/lib/mysql /usr/bin/mariadbd-safe-helper: Can't create/write to file '/var/lib/mysql/opti780-Server.err' (Errcode: 13 "Permission denied")
我查看了类似问题,但无法找到针对我这个情况的确切解决方案。大多数方案都是重启服务,而我已经尝试过,且大多针对Debian Linux。
如果需要更多信息,请告知。再次感谢。
内容的提问来源于stack exchange,提问作者Arash. j.
相关产品推荐
相关产品推荐

