Bug 313914 - MySQL database creation failed when path to the database contains Cyrillic characters
Summary: MySQL database creation failed when path to the database contains Cyrillic ch...
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Collections/Local (show other bugs)
Version: 2.7.0
Platform: Ubuntu Linux
: NOR normal
Target Milestone: 2.8
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-26 02:57 UTC by Artem Vorotnikov
Modified: 2013-05-15 12:55 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.7.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Artem Vorotnikov 2013-01-26 02:57:03 UTC
I have Unicode (cyrillic) user, host names and Unicode home path. Amarok starts with error and fails to import collection:

GREPME MySQLe query failed! (1006) Can't create database 'amarok' (errno: 2) on Could not create amarok database
GREPME MySQLe query failed! (1) Can't create/write to file '/home/аÑÑÑм/.kde/share/apps/amarok/mysqle/amarok/db.opt' (Errcode: 2) on Could not alter database charset/collation
GREPME MySQLe query failed! (1049) Unknown database 'amarok' on Could not select database
GREPME MySQLe query failed! (1049) Unknown database '(null)' on SELECT column_name FROM INFORMATION_SCHEMA.columns WHERE table_name='admin'
GREPME MySQLe query failed! (1049) Unknown database '(null)' on SELECT column_name FROM INFORMATION_SCHEMA.columns WHERE table_name='admin'
GREPME MySQLe query failed! (1049) Unknown database '(null)' on SELECT column_name FROM INFORMATION_SCHEMA.columns WHERE table_name='admin'
GREPME MySQLe query failed! (1046) No database selected on CREATE TABLE admin (component VARCHAR(255), version INTEGER) COLLATE = utf8_bin ENGINE = MyISAM;
GREPME MySQLe query failed! (1046) No database selected on CREATE TABLE devices (id INTEGER PRIMARY KEY AUTO_INCREMENT,type VARCHAR(255),label VARCHAR(255),lastmountpoint VARCHAR(255),uuid VARCHAR(255),servername VARCHAR(80),sharename VARCHAR(240)) COLLATE = utf8_bin ENGINE = MyISAM;
GREPME MySQLe query failed! (1046) No database selected on CREATE INDEX devices_type ON devices( type );
GREPME MySQLe query failed! (1046) No database selected on CREATE UNIQUE INDEX devices_uuid ON devices( uuid );
GREPME MySQLe query failed! (1046) No database selected on CREATE INDEX devices_rshare ON devices( servername, sharename );
GREPME MySQLe query failed! (1046) No database selected on CREATE TABLE urls (id INTEGER PRIMARY KEY AUTO_INCREMENT,deviceid INTEGER,rpath VARCHAR(324) NOT NULL,directory INTEGER,uniqueid VARCHAR(128) UNIQUE) COLLATE = utf8_bin ENGINE = MyISAM;
GREPME MySQLe query failed! (1046) No database selected on CREATE UNIQUE INDEX urls_id_rpath ON urls(deviceid, rpath);
GREPME MySQLe query failed! (1046) No database selected on CREATE INDEX urls_uniqueid ON urls(uniqueid);
GREPME MySQLe query failed! (1046) No database selected on CREATE INDEX urls_directory ON urls(directory);
GREPME MySQLe query failed! (1046) No database selected on CREATE TABLE directories (id INTEGER PRIMARY KEY AUTO_INCREMENT,deviceid INTEGER,dir VARCHAR(1000) NOT NULL,changedate INTEGER) COLLATE = utf8_bin ENGINE = MyISAM;
GREPME MySQLe query failed! (1046) No database selected on CREATE INDEX directories_deviceid ON directories(deviceid);
GREPME MySQLe query failed! (1046) No database selected on CREATE TABLE artists (id INTEGER PRIMARY KEY AUTO_INCREMENT,name VARCHAR(255) NOT NULL) COLLATE = utf8_bin ENGINE = MyISAM;
GREPME MySQLe query failed! (1046) No database selected on CREATE UNIQUE INDEX artists_name ON artists(name);
GREPME MySQLe query failed! (1046) No database selected on CREATE TABLE images (id INTEGER PRIMARY KEY AUTO_INCREMENT,path VARCHAR(255) NOT NULL) COLLATE = utf8_bin ENGINE = MyISAM;

Reproducible: Always
Comment 1 Myriam Schweingruber 2013-01-26 10:13:59 UTC
Try running this as normal user (NOT as root):

mysqlcheck --auto-repair --all-databases

Also I strongly recommend you use Amarok 2.7, sadly you didn't specify which version this is about.
Comment 2 Artem Vorotnikov 2013-01-30 13:17:34 UTC
(In reply to comment #1)
> Try running this as normal user (NOT as root):
> 
> -
> 
> Also I strongly recommend you use Amarok 2.7, sadly you didn't specify which
> version this is about.

I have switched to gentoo, but still get the same error

Amarok 2.7.0, compiled w/ embedded USE flag
Your command yields
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect
Comment 3 Myriam Schweingruber 2013-01-30 15:18:48 UTC
Sounds like a problem on your side, then, please make sure your MySQL is compiled with -fPIC enabled and check your file system permissions. Which MySQL version do you use?
Comment 4 Artem Vorotnikov 2013-01-30 16:33:49 UTC
(In reply to comment #3)
> Sounds like a problem on your side, then, please make sure your MySQL is
> compiled with -fPIC enabled and check your file system permissions. Which
> MySQL version do you use?

MySQL 5.5.29-r1 and do you want me to compile Amarok w/ standalone sql server (USE="-embedded")?
Comment 5 Artem Vorotnikov 2013-01-30 16:48:12 UTC
Mmmm guess what? I don't get the error when I start Amarok via kdesu. This is clearly related to my using Unicode.
Comment 6 Myriam Schweingruber 2013-01-31 09:02:55 UTC
(In reply to comment #5)
> Mmmm guess what? I don't get the error when I start Amarok via kdesu. This
> is clearly related to my using Unicode.

Sorry, but that statement makes no sense :) And it also makes no sense that you run Amarok with root rights, but it clearly shows that there is a permissions issue on your MySQL installation, please make sure that the folder content of $HOME/.kde/share/apps/amarok/mysqle/amarok/ has correct permissions, it should be -rw-rw----
Comment 7 Artem Vorotnikov 2013-01-31 19:21:00 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > Mmmm guess what? I don't get the error when I start Amarok via kdesu. This
> > is clearly related to my using Unicode.
> 
> Sorry, but that statement makes no sense :) And it also makes no sense that
> you run Amarok with root rights, but it clearly shows that there is a
> permissions issue on your MySQL installation, please make sure that the
> folder content of $HOME/.kde/share/apps/amarok/mysqle/amarok/ has correct
> permissions, it should be -rw-rw----

Deleted the folder, started Amarok as normal user. Still the same error.
Comment 8 Myriam Schweingruber 2013-02-01 08:19:41 UTC
You deleted the folder? That was your database, I didn't tell you to delete it...

You didn't answer my question about the MySQL version and whether it was compiled with -fPIC enabled, because this is most likely a problem with your MySQL installation, not with Amarok.

Since mysqlcheck didn't allow you to repair the database and gave you an error this is most likely the culprit
Comment 9 Artem Vorotnikov 2013-02-01 08:30:46 UTC
(In reply to comment #8)
> You deleted the folder? That was your database, I didn't tell you to delete
> it...
> 
> You didn't answer my question about the MySQL version and whether it was
> compiled with -fPIC enabled, because this is most likely a problem with your
> MySQL installation, not with Amarok.
> 
> Since mysqlcheck didn't allow you to repair the database and gave you an
> error this is most likely the culprit
I don't know if it was compiled with -fPIC (I didn't force it, at least)

I created a new user in latin alphanumerics and this problem is NOT present.
Comment 10 Myriam Schweingruber 2013-02-01 08:36:32 UTC
Then something is wrong in your user configs, try erasing your $HOME/.kde/share/config/amarok* for your previous user.

Please take this to the forum at http://forum.kde.org/amarok, it is not an issue that belongs in the bug tracker.
Comment 11 Artem Vorotnikov 2013-02-01 08:40:32 UTC
(In reply to comment #10)
> Then something is wrong in your user configs, try erasing your
> $HOME/.kde/share/config/amarok* for your previous user.
> 
> Please take this to the forum at http://forum.kde.org/amarok, it is not an
> issue that belongs in the bug tracker.

I have wiped all Amarok settings for cyrillic user but I still got the same error on startup.

This is an issue with Amarok/MySQL handling of UTF-8 characters, probably because of Qt's internal usage of UTF-16. Nevertheless, it clearly belongs to the bug tracker.
Comment 12 Artem Vorotnikov 2013-02-01 09:14:33 UTC
GREPME MySQLe query failed! (1) Can't create/write to file '/home/аÑÑÑм/.kde/share/apps/amarok/mysqle/amarok/db.opt' (Errcode: 2) on Could not alter database charset/collation

This is the error. Note the "аÑÑÑм" part. Most likely Qt sends the аÑÑÑм instead of артём to MySQL. In order to solve it, Amarok has to invoke QString::fromUtf8 when sending the path to MySQL.
Comment 13 Kevin Funk 2013-02-01 09:27:00 UTC
I suspect it's an Amarok bug. (Quickly scanned through the code base, so take this with a grain of salt).

MySqlEmbeddedStorage.cpp uses QString::toAscii() to store the database directory location from memory to my.cnf.
The data location ('$HOME/.kde/...') itself comes from kdelibs's KGlobal::dirs(), that should not be an issue wrt encoding.
Comment 14 Artem Vorotnikov 2013-02-01 09:48:05 UTC
(In reply to comment #13)
> I suspect it's an Amarok bug. (Quickly scanned through the code base, so
> take this with a grain of salt).
> 
> MySqlEmbeddedStorage.cpp uses QString::toAscii() to store the database
> directory location from memory to my.cnf.
> The data location ('$HOME/.kde/...') itself comes from kdelibs's
> KGlobal::dirs(), that should not be an issue wrt encoding.

Changing 
datadir = /home/аÑÑÑм/.kde4/share/apps/amarok/mysqle
to
datadir = /home/артём/.kde4/share/apps/amarok/mysqle

does not work. Moreover, on the launch of Amarok home path in my.cnf becomes mojibake again.
Comment 15 Matěj Laitl 2013-04-09 20:11:32 UTC
(In reply to comment #14)
This is the cause:
> Moreover, on the launch of Amarok home path in my.cnf becomes
> mojibake again.

This is the consequence:
> Changing 
> datadir = /home/аÑÑÑм/.kde4/share/apps/amarok/mysqle
> to
> datadir = /home/артём/.kde4/share/apps/amarok/mysqle
> 
> does not work.

> > MySqlEmbeddedStorage.cpp uses QString::toAscii() to store the database
> > directory location from memory to my.cnf.

Looks like an easy fix, I'll have a look at it.
Comment 16 Matěj Laitl 2013-04-09 20:42:46 UTC
Git commit 7b8266baf2f0c3afac70b8cbbc561c473a6f1322 by Matěj Laitl.
Committed on 09/04/2013 at 22:40.
Pushed by laitl into branch 'master'.

MySqlEmbeddedStorage: don't use QString::toAscii(), fix bug 313914

It is 2013. We have more characters than 128.

BUGFIXES:
 * Fix inability to create database when home directory contains
   non-ASCII characters.
FIXED-IN: 2.8

M  +2    -0    ChangeLog
M  +3    -3    src/core-impl/collections/db/sql/mysqlecollection/MySqlEmbeddedStorage.cpp

http://commits.kde.org/amarok/7b8266baf2f0c3afac70b8cbbc561c473a6f1322
Comment 17 Matěj Laitl 2013-05-14 21:25:30 UTC
Git commit e90f7b4b8462e674275b53d550c147bbececd467 by Matěj Laitl.
Committed on 09/04/2013 at 22:40.
Pushed by laitl into branch 'v2.7.x'.

MySqlEmbeddedStorage: don't use QString::toAscii(), fix bug 313914

It is 2013. We have more characters than 128.

BUGFIXES:
 * Fix inability to create database when home directory contains
   non-ASCII characters.

M  +2    -0    ChangeLog
M  +3    -3    src/core-impl/collections/db/sql/mysqlecollection/MySqlEmbeddedStorage.cpp

http://commits.kde.org/amarok/e90f7b4b8462e674275b53d550c147bbececd467