Bookmark This Page! Control + D
If you enjoy this blog,
please consider supporting my band.

Thursday, September 13, 2007

How to: set up MySQL Database in Amarok

I found myself complaining about the slow speed of Amarok. Everything would lag, from playing a song to adding a song to the playlist. Then i remembered when I was setting up Amarok that it let me chose a database, and said the faster ones required extra set up. Of course, I chose the no set up required but slow speed option (SQLlite).

Now, I wanted to switch. And boy am i glad. Everything works as fast as it should.

sudo apt-get install mysql-server mysql-client

now this (replace PASSWORD with your password)

mysqladmin -u root password PASSWORD
then this

mysql -p -u root
CREATE DATABASE amarok;
USE mysql;
GRANT ALL ON amarok.* TO amarok@localhost IDENTIFIED BY 'PASSWORD_CHANGE_ME';
FLUSH PRIVILEGES;
quit

In Amarok, go to settings> configure Amarok
Click Collection

Select MySQL.

Use the following settings:
Hostname: 127.0.0.1
Database: amarok
Port: 3306
Username: amarok
Password: Your Password
You're done! Enjoy the speediness!

Problems? check out the official wiki:
http://amarok.kde.org/wiki/MySQL_HowTo

61 comments:

Kresimir said...

hi,
when i run apt-get, it can't find the libmysqlclient12-dev...
also, what should i put instead of the 'password_change_me' field? my root password?

mike said...

hm... i just did a search myself and could not find it... but it still works.. let me know how it works for you

mike said...

oh and yes, replace that with the password you will enter in amarok settings (not necessarily your root password)

leinir said...

Have you made sure you are actually running Amarok 1.4.7 and not the one that comes with a stock Ubuntu install? That it should be this slow sounds a lot like your installation is older - according to tests done by one of our devs, SQLite should be as fast as MySql for anything up to at least ten thousand of tracks now. Please check it :)

DiggUser said...

Great article to chat about!

Anonymous said...

Does it have a PostgreSQL option? I'd rather use a better database than MySQL - especially since I and most of my more durability-obsessed friends already have PostgreSQL set up.

Anonymous said...

Dude I love postgreSQL as much as you but seriously, if this isn't a time when myISAM is the better tool for the job, then I don't know what is. Pgsql is simply overkill here.

Anonymous said...

And how do i revert all the process?

Anonymous said...

When I set up Amarok, it already had localhost in the host field. I figured that would work. It did not - Amarok gave me a strange error. I fixed it by using 127.0.0.1 - ?!

Anonymous said...

Heh. Personally, I feel like if you care about your data enough to run a database at all, PostgreSQL isn't overkill, it's a baseline. However - we're getting off topic. The question was whether Amarok supported PostgreSQL. Anyone know?

Anonymous said...

yes, there is an option to use PostgreSQL. Since we are talking thousands of records here, I don't think PostgreSQL is overkill (if MySQL isn't overkill then it isn't either) at all. Especially if you have PgSQL set up somewhere and you don't want to deal with the horrible mess that is MySQL.

Anonymous said...

postgresql support page:
http://amarok.kde.org/wiki/PostgreSQL_HowTo
It mentions how to support different users with schemas, a topic not touched on in the MySQL howto.

Joe said...

Wow, I'm fairly new to Ubuntu and this is one of the first times everything has gone smooth. I don't want to debate over db semantics, just wanted to comment that your instructions were straight forward and results are noticeable.

Thanks!!

john said...

Hi Mike,

As a Linux noob, your instructions were flawless. As I have a large music collection, this has been something that I have wanted to do. Thanx.

Anonymous said...

is this the reason people should choose to switch to linux?

diabolic preacher said...

is this the reason people should choose to switch to linux?

no. this is the reason, why people should reconsider using Amarok.

emonk said...

mysql sucks, postgresql rules :)

Kables said...

Thank god for this post. At 28,000 tracks Amarok was hardly usable; now it speeds along like the rest of my system.

Anonymous said...

Canadian Pharmacy - We offer a wide selection of the most popular medicines online.

Anonymous said...

This post preserved another amarok user. I was about to ditch it for another media player until this post noticeably speeded it up. Thanks :)

<a href="http://free.7host07.com/nmcfgy/495.html">amalfi coast tour</a> said...
This post has been removed by a blog administrator.
Anonymous said...

I could not make amarok work using your instructions. I found that I had to enter the username as "root" in amarok, instead of user "amarok." Otherwise the instructions worked. I don't know if it matters, but I am using amarok under Gnome.

Sean said...

I ditched Amarok a while back and was using Exiale but it suffered similar performance problems.
I decided to try Amarok again and through the install process was reminded about the backend DB options, I found the instructions when the built in link for MySQl was not working - talk about simplifying the process. Thanks Mike - its literally 5 min later and I'm rockin' out right now!

Xeper said...

Simple instructions to achieve a goal in minimal time. Awesome.

After running through this, I decided to go with PostgreSQL anyway, and I have to say it's light years faster than SQLite and noticeably faster than MySQL.

My library is greater than 8000 tracks. I would recommend to everyone with 8000+ tracks to give PostgreSQL... it's far superior.

Mr. Garofalo said...

I run Gutsy and have a library around 15,000 songs. Amarok runs MUCH more smoothly now. Thank you!

Anonymous said...

Thanks very much for your blog, but I must say that it wasn't very concise. I'm not sure where you got your "use these settings" from, but they certain;y didn't work for me. Your blog deviates from the official instructions for enabling MySQL with Amarok: http://amarok.kde.org/wiki/MySQL_HowTo#MySQL_Setup

Though you do provide help with installing the program via the Terminal, your instructions for setting up and implementing MySQL were a little flawed.

Thanks anyway though...

evil_m0nkey said...

i get this error

error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

and i opened that folder and i dont see the .sock file,
any idea what i should do now?
i would really appreciate if u could get back to me
THANKS A MILLION

Irving said...

In Amarok Collection Configuration, you must put:

"Hostname: Localhost"

Putting an IP will give you an user/pass error

Anonymous said...

Awesome howto!
Worked perfectly!
A million thanks =D

stream said...

hi, i get the following error after i run the 2nd command...

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

stream said...

hi, i get this error when i run the 2nd command...

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'


thanks in advance

Anonymous said...

These are very simple and straight forward instructions. Thanks! Also on a similar note, mySQL is a great DB. I use it for several different purposes from website use to personal budgeting. I've never had any problems with it. I am curious (since I have not yet tried postgreSQL), why do some users prefer this over mySQL?

Michael said...

Hi,

I get this same error...

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

Anyone have any ideas of resolving this?

Thanks

Anonymous said...

Mike,

you are awesome dude. This cant be simpler. I have read other How-tos too but could never configure MySQL for Amarok.

You Rock.

Thanks,

God bless you.

Rakesh Gupta

Anonymous said...

There's a nice compliment to the MySQL solution you have here. Combining both of them works nicely.
Here's the link to that one: http://ubuntulinuxhelp.com/how-to-speed-up-amarok-part-1/

Anonymous said...

stream, skip that second command. worked fine for me without it. got the same messg as you.

mike, thanks for the tutorial.

Anonymous said...

I'm running Gutsy. When I installed mysql- client & server I gave the program a password. Now I can not log in using that password or change the password.

# mysqladmin -u root password password
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

However after messing around, removing, purging, reinstalling, etc. the suggested command still wouldn't connect. What I found that worked was:

$ mysql -p -u root

I gave it the password I'd set up initially and was able to configure mysql with amarok as suggested. You guys that are having problems might give that a try.

Nicholas said...

This was very helpful. But now i have a new computer and want to transfer the mysql amarok database over to it (all my favorite tracks, times played, etc.) Does anyone now how to do that?


PS - I am putting all of the music files in the same directory locations (Basically copied all the shared music in a same named file hierarchy. I dont know if that helps at all.)

Johan said...

Great howto Mike!

Have it bookmarked now so i can get back to it every time i mess something up ;P

Thanks a bunch ;)


Johan

Anonymous said...

Thanks a lot, I couldn't setup Amarok and MySQL without this blog article.

However, the recent version of MySQL package asks you to root password during its installation, so that the command line to set it, "mysqladmin -u root password PASSWORD" isn't needed after you've installed MySQL package. :)

Cedric said...

Great tips! Thanks a lot. Now amarok works as smooth as I expected.

As last comment states, it's true that with mysql-server-5.0 there is no need to set root password from terminal with the given command.

This kind of post are those that should be bookmarked ;)

Crazypig said...

I've changed from sqlite to mysql as suggested, re builit my collection and everything is there except the play count/rating/score information. Can I copy it from sqlite? If I change amarok settings back to use sqlite all the info is there but not with amarok set to mysql. Where is this data stored and how can mysql see it? Any ideas.

MikeP said...

Oh dear, you're right, no ratings! :(

HELP!!!

MikeP said...

PS - see this one through, as even though I'm not sure I got 100% of my stats, I got the majority. Sorry for the blow by blow, but try this one:

http://amarok.kde.org/wiki/MySQL_HowTo:

In particular
[QUOTE]An alternate method is to import my SQLite data as follows:

* Start Amarok, change to MySQL, and build the database (but don't play any songs)
* Download SQLite Database Browser
* Export the statistics database to a dump file, amarok_dump.sql
* Remove all BEGIN TRANSACTION, COMMIT and CREATE sql commands
* Import the file using MySQL:
[/QUOTE]

Let me know if this works as it's somewhat obtuse directions.

Tony Martinez said...

Beautiful and awesome, it's really faster.
Thank you Mike

Anonymous said...

Heh, it seems that many trolls we have here and postrgre fanboys. How can you measure performance of MySQL and PostgreSQL in Amarok? You just sound like idiots to me :D In benchmarks MySQL eats Postgre at breakfast, so have a nice trolling...

pradeepjey said...

Thanks for the tutorial. Works great!

By the way, it may be worth noting on my fresh install of Intrepid the root password is the same as my sudo password so the first step was not needed. That said I only have one user on my system.

Felipe said...

Worked well in opensuse 11.0. Install "mysql" and "mysql-client" from zypper or yast. If you lost/forget password, try Recover your MySQL Password. Get familiar with "pgrep" and "pkill" because I was NOT using Debian (as that webpage was).

Good Luck.

Felipe

Anonymous said...

Works well. The new version of mysql logs you in, so this line:
mysqladmin -u root password PASSWORD
isn't necessary and won't work.

Anonymous said...

lol, I tought I had failed. But I had to rescan the library :D

Anonymous said...

thank you. it used to kill me, was so slow. it works perfect now.

backup solution said...

Thank you for this post! How useful!

confy said...

I can confirm this... it's mysql solved my problem.
However, isn't this too much for amarok? mysql 5? :(

all i want is music player and not music machine... :(

Anonymous said...

does this work for a dj panel, shoutout - requests etc. please get back to me.

mike said...

yeah I think it would work fine for a DJ setup

remote backup said...

Thanks for the instructions. We all need some help now and again.

Anonymous said...

Thanks, so simple yet so needed.

ubuntonian said...

Worked flawlessly. Thanks!

Anonymous said...

Thank you.

Anonymous said...

Thx a million

I needed to reinstall MySQl database as I went from Amarok 2 back to Amarok 14

Hint I needed to add sudo to the MYSQL commands otherwise I reveice a weird error

sudo MYSQL -p root

Juan said...

I recently came accross your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.


Betty

http://electricguitarhowtoplay.net