1

Background

Hi. I'm new to home servers (and maybe linux tbh) and am trying to set "nextcloud" up and running. I'm running a Linux 6.1.0-1 Manjaro (so Arch linux), and I'm mainly accessing it through SSH. I'm following this guide on arch wiki, step by step.

What i did before the error produced

I followed the aforementioned guide successfuly until part 4.4 MariaDB/MySQL:

As the guide directed, I installed mariadb, using sudo pacman -S mariadb. then initialized using mariadb-install-db command. the prompted suggested that i had successfuly initialized and had 2 user databases (sorry for my possibly wrong terminology) named root, and arash (my user).

I made changes to my /etc/my.cnf.d/server.cnf, again, as directed. this is my /etc/my.cnf.d/server.cnf now:

#
# 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]

The error

The step right after that, which was connecting to my root database ($ mysql -u root -p) produced the following error which is what im trying to solve:

$ mysql -u root -p 
Enter password: 
ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)

I thank anyone helping in advance. :* . more information:

Things i have tried

My first thought was maybe the service or socket wasn't running, so i starting the service using systemctl. the service would enable, but would not 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.

and the systemctl status mariadb results in:

$ 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.
~
~
~

Then, I tried uncommenting (adding, i suppose) the bind-address=0.0.0.0 in /etc/my.cnf.d/server.cnf as it was advised by someone, but it produced no difference.

I also tried removing mariadb and re-installing:

pacman -R mariadb
pacman -S mariadb

and then tried these codes for initialization and daemon starting instead of one's suggested by the guide:

mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

result: the problem continued

ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (111)

and

cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'

result: the problem continued

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")

I tried similar questions on site but i could not figure out a deffinitive answer for my exact problem. most of them included restarting services which i have already tried. and also they are mostly for debian linux :( .

if you need more information kindly let me know. thankyou again.

Arash. j.
  • 11
  • 2

1 Answers1

0

The mysql_install_db, now called mariadb-install-db in MariaDB, would have populated the /var/lib/mysql directory correctly.

mysqld_safe isn't starting because it isn't starting as the mysql user, however you don't need to start it.

Just start the service:

systemctl start mariadb.service and it will start.

danblack
  • 12,130
  • 2
  • 22
  • 41