Ad Widget

Collapse

Database error : Error connecting to database: No such file or directory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FildaSmile
    Member
    • Jul 2019
    • 61

    #1

    Database error : Error connecting to database: No such file or directory

    Hello,

    yesterday i tried install: mysql odbc drivers in ubuntu 18.04 [https://medium.com/@joelzhang/instal...4-39241072326a], unfortunately the testing goes wrong and now zabbix is not able to connect to DB.


    The error message is: "Error connecting to database: No such file or directory"

    When i try mysql command in shell the result is: zabbix@zabbix-virtual-machine:~$ mysql
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

    /var/log/mysql/error.log is empty

    I tried do the mysql odbc drivers in ubuntu 18.04 installation backwards and uninstall the drivers and parent files and apps but it didnt help.

    when i try "sudo mysqld" :


    root@zabbix-virtual-machine:~# sudo mysqld
    2020-05-28T06:26:53.253803Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2020-05-28T06:26:53.255757Z 0 [Warning] Insecure configuration for --secure-file-priv: Location is accessible to all OS users. Consider choosing a different directory.
    2020-05-28T06:26:53.255810Z 0 [Note] mysqld (mysqld 5.7.30-0ubuntu0.18.04.1) starting as process 22570 ...
    2020-05-28T06:26:53.258275Z 0 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

    2020-05-28T06:26:53.258325Z 0 [ERROR] Aborting

    2020-05-28T06:26:53.258343Z 0 [Note] Binlog end
    2020-05-28T06:26:53.258389Z 0 [Note] mysqld: Shutdown complete

    Im DEV environment and now i thinking if it is posible to repair or reinstall DB or if i must reinstall whole zabbix (i have backup of hosts and templates) of course i will be very happy if we can save the DB or at least save the zabbix server and reinstall only MariaDB.

    I using Zabbix 4.4

    Thanks for any advice or help.
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    When you ran "sudo mysqld", the shell prompt (#) suggests that you were already the root user, so using sudo with no other command line flags there was not needed.

    Typically, you don't run the MySQL or MariaDB server binary (mysqld) directly as the root user. Usually there's a startup procedure that gets the daemon set up and has it run as a lesser-privileged user, often 'mysql' but a Linux distro can choose something else instead.

    I don't use Ubuntu, but I believe that Ubuntu has adopted 'systemd', which means that service control for daemons is typically done via the 'systemctl' command. The service file for mariadb should already have all the settings that systemd needs to know about to properly start the 'mysqld' server process. That means that to start it, you would typically do

    If you already have a root shell, just type: systemctl start mariadb.service

    If you're using your normal (non-root) account, then: sudo systemctl start mariadb.service

    If that fails, you run

    systemctl status -l mariadb.service

    and examine what the error message(s) is/are telling you. Again, prefix that command with 'sudo' only if you're not already running as root.

    If startup fails and you're not sure what any error messages in the 'status -l' output are saying, post them in this thread and hopefully someone will have some ideas for how to help you further.

    A couple more suggestions -- these are just my opinions, but they're based on experience, so they might be useful to you:
    1. since you seem to be running in a VM environment, you may want to get into the habit of taking a VM snapshot before doing anything potentially destructive or that you can't easily undo. That way, if there's a problem, you just roll back to the VM snapshot. If there are no problems, you can just delete the snapshot.
    2. Most modern Linux distros use a packaging system. Ubuntu, because it's based on Debian, uses 'deb' packages. Sometimes it may seem like the packaging system is preventing you from doing something you think you should, but usually it's doing so for a very good reason. Any random blog post that you find that tells you to side-step your distro's packaging system and start copying binaries and libraries directly onto you system is probably written by someone that doesn't know how much trouble they're eventually going to cause. Both mysql and MariaDB provide packages for their ODBC drivers, so it's pointless (and potentially harmful) to skip the packages and download these binaries. It would have been much better to just use the packages.

    Comment

    • FildaSmile
      Member
      • Jul 2019
      • 61

      #3
      Hello thank you for feedback, i must agree with you about the snapshot next time i´ll think twice.

      Unfortunately i did not recieve any results from the commands, it is possible just to uninstall MariaDB or its leftovers and install it again ?

      root@zabbix-virtual-machine:~# sudo systemctl start mariadb.service
      Failed to start mariadb.service: Unit mariadb.service not found.
      root@zabbix-virtual-machine:~# systemctl status -l mariadb.service
      Unit mariadb.service could not be found.

      thank you in advance

      Comment

      • KBlasz
        Junior Member
        • Apr 2020
        • 20

        #4
        Hello, i have had these issues in the past too and was never able to figure it out (i work with mssql so linux database apps are completely mind breaking to me). best recommendation is to never do anything on the main zabbix server unless you really know what you are doing. I have been setting up ODBC on proxies, this way if something happens to break, you only lose a proxy, not the whole monitoring setup.

        Comment

        • zackxoxo
          Junior Member
          • May 2020
          • 1

          #5
          I can't get into the game, it tells me there's server problems and a "Database error" message pops up. Anybody knows how to fix it?192.168.0.1 routerlogin 192.168.l.l
          Last edited by zackxoxo; 28-05-2020, 19:00.

          Comment

          • tim.mooney
            Senior Member
            • Dec 2012
            • 1427

            #6
            Originally posted by FildaSmile
            Unfortunately i did not recieve any results from the commands, it is possible just to uninstall MariaDB or its leftovers and install it again ?

            root@zabbix-virtual-machine:~# sudo systemctl start mariadb.service
            Failed to start mariadb.service: Unit mariadb.service not found.
            root@zabbix-virtual-machine:~# systemctl status -l mariadb.service
            Unit mariadb.service could not be found.
            Ok, I probably guessed the wrong service name based on some Ubuntu-related documentation I was reading.

            To get 'systemctl' to tell us about all of the "units" it knows about, and to filter for ones that contain "my" or "maria", do this:

            Code:
            systemctl list-units | egrep -i 'my|maria'
            Hopefully that will give you one service name (it will likely end with ".service"). Once you know that, try using the "systemctl start" with that service name.

            Comment

            • aib
              Senior Member
              • Jan 2014
              • 1615

              #7
              check this https://tableplus.com/blog/2018/08/s...gh-socket.html
              Sincerely yours,
              Aleksey

              Comment

              Working...