Ad Widget

Collapse

can't load images into database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acceleratebiz
    Junior Member
    • Oct 2005
    • 12

    #1

    can't load images into database

    I'm trying to install the latest beta of Zabbix and can't install the images.sql rows. I keep getting errors with that load_file string function with mysql as it always returns null no matter what I do. Here's the description in mysql docs:
    LOAD_FILE(file_name)

    Reads the file and returns the file contents as a string. The file must be located on the server, you must specify the full pathname to the file, and you must have the FILE privilege. The file must be readable by all and be smaller than max_allowed_packet bytes.

    If the file doesn't exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL.


    zabbixdbuser (my mysql user) has File_priv = 'Y':
    mysql> select * from user where User='zabbixdbuser';
    +-----------+--------------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
    | Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv |
    +-----------+--------------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
    | localhost | zabbixdbuser | 4b81fbf24265bc39 | N | N | N | N | N | N | N | N | N | Y | N | N | N | N |
    +-----------+--------------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+
    1 row in set (0.00 sec)


    I don't know how to check the size of "max_allowed_packet", but the default is supposed to be 1mbyte and I never changed that.


    mysql> insert into images values(1,1,"Hub",load_file("/home/zabbix/zabbix/create/data/images/Hub.png"));
    ERROR 1048: Column 'image' cannot be null
    mysql> \q
    Bye
    [zabbix@manager data]$ ls -lh /home/zabbix/zabbix/create/data/images/Hub.png
    -rw-r--r-- 1 zabbix zabbix 1.9K Jul 29 2004 /home/zabbix/zabbix/create/data/images/Hub.png


    Oh and my mysql version is 3.23.58.
  • James Wells
    Senior Member
    • Jun 2005
    • 664

    #2
    Greetings,

    Right off the bat, it appears that you did not edit the images.sql to correct the path to the image files. Please look at the images.sql and make sure the full path and file name is correct for where the files on your server.
    Unofficial Zabbix Developer

    Comment

    • acceleratebiz
      Junior Member
      • Oct 2005
      • 12

      #3
      I did try modifying the paths. I used relative paths. I tried copying some images to the /tmp directory and reference /tmp/Hub.png, for example. Take a look at the end of my post:
      mysql> insert into images values(1,1,"Hub",load_file("/home/zabbix/zabbix/create/data/images/Hub.png"));
      ERROR 1048: Column 'image' cannot be null
      mysql> \q
      Bye
      [zabbix@manager data]$ ls -lh /home/zabbix/zabbix/create/data/images/Hub.png
      -rw-r--r-- 1 zabbix zabbix 1.9K Jul 29 2004 /home/zabbix/zabbix/create/data/images/Hub.png
      my directory structure is the same as the example entries in the images.sql file. You can see this by my "ls -lh" statement.

      Comment

      • James Wells
        Senior Member
        • Jun 2005
        • 664

        #4
        Arrrggg. Sorry, teach me to try to answer posts without having my 4th cup of cofee...

        What version of Zabbix are you using please. It is looking like there is a schema mis-match here.
        Unofficial Zabbix Developer

        Comment

        • acceleratebiz
          Junior Member
          • Oct 2005
          • 12

          #5
          I'm using the latest 1.1beta, I just downloaded it yesterday

          Comment

          • James Wells
            Senior Member
            • Jun 2005
            • 664

            #6
            Hmmm, okay, the schema is correct. Try this please, replace all instances of double quotes around the path/filename with single quotes and try to load it again.

            Additionally, please check to make sure that the mysql user and the user you are running the mysql client as has the ability to read the image files.
            Unofficial Zabbix Developer

            Comment

            • acceleratebiz
              Junior Member
              • Oct 2005
              • 12

              #7
              hmm, good idea about the quotes, but didn't work
              Code:
              mysql> insert into images values(1,1,'Hub',load_file('/home/zabbix/zabbix/create/data/images/Hub.png'));
              ERROR 1048: Column 'image' cannot be null
              mysql>
              From my first post on this thread, I copied the load_file() string function from mysql docs. I showed (I think?) that I have the file privileges for zabbixdbuser. Am I correct? I'm no expert in mysql...

              Comment

              • James Wells
                Senior Member
                • Jun 2005
                • 664

                #8
                Originally posted by acceleratebiz
                From my first post on this thread, I copied the load_file() string function from mysql docs. I showed (I think?) that I have the file privileges for zabbixdbuser. Am I correct? I'm no expert in mysql...
                Sorry, who is the MySQL server running as, and who are you executing the MySQL client as? Not the database user, but the unix system users...
                Unofficial Zabbix Developer

                Comment

                • Alexei
                  Founder, CEO
                  Zabbix Certified Trainer
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Sep 2004
                  • 5654

                  #9
                  Perhaps my notes in ZABBIX Manual will shed some light: http://www.zabbix.com/manual/v1.1/install_server.php
                  Alexei Vladishev
                  Creator of Zabbix, Product manager
                  New York | Tokyo | Riga
                  My Twitter

                  Comment

                  • acceleratebiz
                    Junior Member
                    • Oct 2005
                    • 12

                    #10
                    Hi James, the mysql server is run under root and the user is "zabbix", a new user I created just for this. I untarred the application under the /home/zabbix directory.

                    Alexei, thanks for chiming in. I followed these instructions originally. The only relevant note I see is the following
                    Note: Unfortunately MySQL does not support relative path in statement load_file(). You may want to edit images.sql to replace locations of image files. Also make sure that MySQL super-user (usually mysql) has read access to these files. If you still have any problems, copy images to directory /tmp, assign read permissions, change load_file() in images.sql, and execute images.sql.
                    I actually tried entering the commands directly into the mysql client with every kind of path imaginable including /tmp. As you can see from my 'ls -lh' command, the Hub.png file which I tried inserting has read permissions for everyone.

                    Comment

                    • elkor
                      Senior Member
                      • Jul 2005
                      • 299

                      #11
                      Ok, as we appear to firmly be in the "nobody knows why this is happening" camp I'll chime in with some stupid stuff to check:

                      can you verify the table structure for images in mysql with a "describe images". I expect it to be correct but it can't hurt to double check.

                      also.... in your path to the images file, are there any directories which the mysql or zabbix SYSTEM users do not have access to?

                      i.e. can the mysql system user execute that same ls command.

                      also, are there any symlinks in the path? if it doesn't like relative paths maybe it doesn't like symlinks either....


                      edit: oh meh, you said you tried tmp.
                      does it work adding them through the frontend?

                      Comment

                      • Alexei
                        Founder, CEO
                        Zabbix Certified Trainer
                        Zabbix Certified SpecialistZabbix Certified Professional
                        • Sep 2004
                        • 5654

                        #12
                        Just a guess, perhaps MySQL is running in some secured (chroot?) environment?
                        Alexei Vladishev
                        Creator of Zabbix, Product manager
                        New York | Tokyo | Riga
                        My Twitter

                        Comment

                        • acceleratebiz
                          Junior Member
                          • Oct 2005
                          • 12

                          #13
                          figured it out!

                          Hi guys, a coworker figured it out! the problem was the max_allowed_packets setting was in the /etc/my.cnf file and needed to be set to some high value. Thanks for trying to help though I appreciate it.

                          never said I was a mysql expert

                          Comment

                          • Alexei
                            Founder, CEO
                            Zabbix Certified Trainer
                            Zabbix Certified SpecialistZabbix Certified Professional
                            • Sep 2004
                            • 5654

                            #14
                            Thanks for the hint. ZABBIX Manual updated.
                            Alexei Vladishev
                            Creator of Zabbix, Product manager
                            New York | Tokyo | Riga
                            My Twitter

                            Comment

                            • Khach
                              Junior Member
                              • Oct 2005
                              • 2

                              #15
                              Hi acceleratebiz? I have the same problem with 1.1beta2. What is the value you changed it to? I can't seem to find the setting in /etc/my.cnf.

                              I am running CentOS 4.1 with mysql-4.1.12-3.RHEL4.1

                              Here is my /etc/my.cnf

                              [mysqld]
                              datadir=/var/lib/mysql
                              socket=/var/lib/mysql/mysql.sock
                              # Default to using old password format for compatibility with mysql 3.x
                              # clients (those using the mysqlclient10 compatibility package).
                              old_passwords=1

                              [mysql.server]
                              user=mysql
                              basedir=/var/lib

                              [mysqld_safe]
                              err-log=/var/log/mysqld.log
                              pid-file=/var/run/mysqld/mysqld.pid

                              Comment

                              Working...