Bug 185395

Summary: Table 'mysql.servers' doesn't exist
Product: [Frameworks and Libraries] Akonadi Reporter: Nick Shaforostoff <shafff>
Component: serverAssignee: Volker Krause <vkrause>
Status: RESOLVED FIXED    
Severity: normal CC: bugs, christopherheiny, gokcen.eraslan, Heinrich20, kde, l.prugger, null, rdieter, romainguinot, sitter
Priority: NOR    
Version: 4.2   
Target Milestone: ---   
Platform: Debian testing   
OS: Unspecified   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Nick Shaforostoff 2009-02-24 00:08:04 UTC
Version:            (using KDE 4.2.0)
Installed from:    Debian testing/unstable Packages

i compiled mailody from trunk  and installed it into /usr (kde 4.2).
i also installed latest (4.2) akonadi-server akonadi-kde packages from debian.
on start mailody reports mysql log:

090224  0:53:53 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them
090224  0:53:53 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
090224  0:53:53 [ERROR] Cannot open mysql.db
090224  0:53:53 [ERROR] Cannot open mysql.user
090224  0:53:53 [ERROR] Cannot open mysql.event
090224  0:53:53 [ERROR] Event Scheduler: An error occurred when initializing system tables.
090224  0:53:53 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.30-2-log'  socket: '/home/xx/.local/share/akonadi/db_misc/mysql.socket'  port: 0  (Debian)
Comment 1 Romain GUINOT 2009-08-27 18:16:12 UTC
Have just solved that one out : 

You need to run /usr/bin/mysql_install_db --datadir=$HOME/.local/share/akonadi/db_data

It will install the mysql database which is missing in the instance that akonadi uses. 
This probably should be run by Akonadi's first run script
Comment 2 Nicolas L. 2009-10-16 17:37:17 UTC
in the sources this is done in ./server/src/storage/akonadi-mysql-server.sh but it seems that this file isn't installed
Comment 3 Nick Shaforostoff 2009-10-16 18:05:41 UTC
i don't like the increased complexity. i could live with sqlite on a netbook, but until then i apt-get purge kontact.
Comment 4 Nicolas L. 2010-02-22 11:05:06 UTC
maybe it should be executed in bool Akonadi::DataStore::init() from server/src/storage/datastore.cpp
Comment 5 Harald Sitter 2010-03-06 12:09:32 UTC
*** Bug 218204 has been marked as a duplicate of this bug. ***
Comment 6 Harald Sitter 2010-03-06 12:10:11 UTC
*** Bug 178157 has been marked as a duplicate of this bug. ***
Comment 7 Harald Sitter 2010-03-21 12:00:58 UTC
Kubuntu bug report:
https://bugs.launchpad.net/ubuntu/+source/akonadi/+bug/448705
Comment 8 Volker Krause 2010-03-21 12:49:22 UTC
SVN commit 1105780 by vkrause:

Some MySQL versions need an explicit run of mysql_install_db when
creating the database initially. So, let's do that if mysql_install_db
is found.

BUG: 185395


 M  +9 -0      dbconfigmysql.cpp  
 M  +1 -0      dbconfigmysql.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1105780
Comment 9 Nicolas L. 2010-04-06 09:56:19 UTC
SVN commit 1111602 by nlecureuil:

Backport commit 1105780
Use mysql_upgrade to fix creation of some tables when the db already exist

BUG:185395 


 M  +16 -0     akonadi.cpp  
 M  +12 -0     storage/dbconfig.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1111602
Comment 10 Nicolas L. 2010-04-06 10:33:40 UTC
SVN commit 1111609 by nlecureuil:

Add forgotten file in previous commit

BUG:185395 



 M  +6 -0      dbconfig.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1111609
Comment 11 Nicolas L. 2010-04-06 10:54:06 UTC
SVN commit 1111611 by nlecureuil:

Forward port of commit 1105780
Change mysql_install_db by using --force and give it a default conf file to use
BUG:185395


 M  +9 -2      dbconfigmysql.cpp  
 M  +1 -0      dbconfigmysql.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1111611
Comment 12 Nicolas L. 2010-04-07 15:40:24 UTC
*** Bug 232702 has been marked as a duplicate of this bug. ***
Comment 13 Gökçen Eraslan 2010-04-09 13:47:00 UTC
When I try to start akonadi via 'akonadictl restart command', I'm getting "[akonadiserver] FATAL ERROR: Upgrade failed" error.

I can easily reproduce the error with the command below:

mysql_upgrade --socket=/home/hede/.local/share/akonadi/db_misc/mysql.socket

Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock' '--socket=/home/gokcen/.local/share/akonadi/db_misc/mysql.socket' 
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock' '--socket=/home/gokcen/.local/share/akonadi/db_misc/mysql.socket' 
akonadi.collectionattributetable                   OK
akonadi.collectionmimetyperelation                 OK
akonadi.collectionpimitemrelation                  OK
akonadi.collectiontable                            OK
akonadi.flagtable                                  OK
akonadi.mimetypetable                              OK
akonadi.parttable                                  OK
akonadi.pimitemflagrelation                        OK
akonadi.pimitemtable                               OK
akonadi.resourcetable                              OK
akonadi.schemaversiontable                         OK
Running 'mysql_fix_privilege_tables'...
ERROR 1049 (42000): Unknown database 'mysql'
FATAL ERROR: Upgrade failed


"mysql_fix_privilege_tables" command fails to execute since there is no DB named 'mysql' in Akonadi. Is this normal or a distro specific issue?

(I'm using MySQL 5.1.41 / Akonadi 1.3 branch from kdesupport / KDE 4.4)
Comment 14 Gökçen Eraslan 2010-04-09 15:13:33 UTC
The problem is in this commit[1], /etc/akonadi/mysql-global.conf path is hardcoded, but this can be changed during build time using -DCONFIG_INSTALL_DIR=/foo. 

XdgBaseDirs::findResourceFile( "config", QLatin1String( "akonadi/mysql-global.conf" )) should be used instead.

Can you fix this?

PS: Also in server/src/storage/akonadi-mysql-server.sh file, there is a line "globalconfig=$KDEDIR/share/akonadi/mysql-global.conf". You may be change this also.


[1] http://websvn.kde.org/?revision=1111602&view=revision
Comment 15 Nicolas L. 2010-04-09 15:33:53 UTC
was planned. i do it now
Comment 16 Nicolas L. 2010-04-09 15:43:50 UTC
SVN commit 1112923 by nlecureuil:

Fix hardcoded conf file
tks to : Gokcen Erasla
CCBUG:185395
CCMAIL:gokcen@pardus.org.tr


 M  +2 -1      akonadi.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1112923
Comment 17 Nicolas L. 2010-04-09 15:49:33 UTC
SVN commit 1112925 by nlecureuil:

Forward port commit 1112923
CCBUG:185395


 M  +2 -1      dbconfigmysql.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1112925
Comment 18 Nicolas L. 2010-06-04 11:16:50 UTC
*** Bug 240695 has been marked as a duplicate of this bug. ***