Database initialization problem.

Started by Nikita Matov, April 16, 2008, 03:43:14 PM

Previous topic - Next topic

Nikita Matov

Hello, Victor!

I was trying to reinstall NetXMS server, and as I did I was trying to re-initialize database:
/usr/local/netxms/bin/nxdbmgr init /usr/local/netxms/share/netxms/sql/dbinit_mysql.sql
NetXMS Database Manager Version 0.2.20

Configuration file OK
Initializing database...
SQL query failed:
CREATE TABLE config
(
var_name varchar(63) not null,
var_value varchar(255) not null,
is_visible integer not null default 1,
need_server_restart integer not null default 0,
PRIMARY KEY(var_name)
)
Database initialization failed

Permissions for database schould be ok, because I defined in netxmsd.conf to connect as root.

Then I tried to initialize database manually, so I did: cat /usr/local/netxms/share/netxms/sql/dbinit_mysql.sql | mysql -u root -p
Tables were created, but then:

/usr/local/netxms/bin/netxmsd -D 9
Using configuration file "/etc/netxmsd.conf"
Configuration file OK
[16-Apr-2008 17:08:51] Unable to set codepage to ISO-8859-1
[16-Apr-2008 17:08:51] Platform subagent "/usr/local/netxms/lib/libnsm_linux.so" successfully loaded
[16-Apr-2008 17:08:51] Database driver "/usr/local/netxms/lib/libnxddr_mysql.so" loaded and initialized successfully
[16-Apr-2008 17:08:51] DEBUG: New DB connection opened: handle=0x617250
[16-Apr-2008 17:08:51] DEBUG: Successfully connected to database [email protected]
[16-Apr-2008 17:08:51] DEBUG: Failed sync query: "SELECT var_value FROM config WHERE var_name='DBFormatVersion'" [0 ms]
[16-Apr-2008 17:08:51] SQL query failed (Query = "SELECT var_value FROM config WHERE var_name='DBFormatVersion'")
[16-Apr-2008 17:08:51] Your database has format version 0, but server is compiled for version 78

But if I go in MySQL and manually do SELECT var_value FROM config WHERE var_name='DBFormatVersion' it returns:
+-----------+
| var_value |
+-----------+
| 78        |
+-----------+
1 row in set (0.00 sec)

I am using Mysql, during re-installation i dropped netxms database. I tried to install different versions of MySQL, and I tried to re-compile NetXMS server.

Alex Kirhenshtein

Quote from: Nikita Matov on April 16, 2008, 03:43:14 PM
Then I tried to initialize database manually, so I did: cat /usr/local/netxms/share/netxms/sql/dbinit_mysql.sql | mysql -u root -p
Tables were created, but then:

Hello.

Looks like you have created tables in "mysql" databse. Try to "cat ... | mysql -u root -p netxms"

Nikita Matov

#2
Quote from: Alex Kirhenshtein on April 16, 2008, 04:24:03 PM
Looks like you have created tables in "mysql" databse. Try to "cat ... | mysql -u root -p netxms"

cat /usr/local/netxms/share/netxms/sql/dbinit_mysql.sql | mysql -u root -p netxms
Enter password:
ERROR 1050 (42S01) at line 1: Table 'config' already exists

As I said before:
But if I go in MySQL and manually do use netxms; SELECT var_value FROM config WHERE var_name='DBFormatVersion'; it returns:
+-----------+
| var_value |
+-----------+
| 78        |
+-----------+
1 row in set (0.00 sec)

I've tried to install previous version of NetXMS - result is the same.
As I understand for some reason netxms cannot read or write to database, why can this be?

Nikita Matov

Everything is ok now. The problem was in MySql.