How-To Geek

Speed Up Amarok With Large Music Collections

Amarok is a wonderful application for managing and playing your music collection, but the default settings aren’t optimized for speed when it comes to large collections of music. The problems are especially noticeable while trying to use the search box.

The problem is that the default embedded database uses sqlite to store the collection information, which doesn’t scale quite as well as a dedicated database such as MySQL… so we’ll switch to use that instead.

Configuring MySQL for Amarok

These instructions assume that you don’t already have MySQL installed. If you are already using it, then just skip the first couple of steps.

Assuming you are using Ubuntu, run this command from a terminal to install the MySQL server and client on your system:

sudo apt-get install mysql-client mysql-server

For security’s sake, you should probably set a root password for your MySQL server using this command:

sudo mysqladmin -u root password “mynewpassword”

You can use the “flush privileges” command or just restart MySQL:

sudo /etc/init.d/mysql restart

Next we’ll use the mysqladmin command to create a database for Amarok to use:

sudo mysqladmin -u root -pMyRootPassword create amarokdb

The final command line step will setup the user account for Amarok in MySQL. Make sure to use a different password here.

mysql -u root -pMyRootPassword

> GRANT ALL ON amarokdb.* TO amarok@localhost IDENTIFIED BY ‘amarokpassword’;


Configuring Amarok

Open the Amarok configuration dialog via the tools menu and then pick the Collection icon on the left.


Change the drop-down to MySQL, and then enter in your details:

  • Hostname: localhost
  • Database: amarokdb
  • Username: amarok
  • Password: password from step above

Close out of the dialog, and then you’ll have to rescan your collection to move everything into MySQL, which might take a little while the first time.

Enjoy the speedy searching!

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 11/6/07

Comments (19)

  1. Kris

    I did this a couple of months back, and it made a dramatic difference. Suddenly I’m again very happy with Amarok.

  2. Henri Gabriel

    The two SQL statements require semi-colons as terminators:

    mysql -u root -pMyRootPassword
    > GRANT ALL ON amarokdb.* TO amarok@localhost IDENTIFIED BY ‘amarokpassword’;

  3. Bert

    Thanks for that last comment; I couldn’t get it to work.

  4. The Geek

    Sorry about the confusion on that… updating article.

  5. Bejron

    Dosn’t work at all here.
    Got prompted after install to create a password.
    “mysqladmin -u root password “mynewpassword”” didn’t work of course since password already was created.
    “/etc/init.d/mysql restart” Didn’t wotk wither, “No permisson/access” (running localised version) and then gave up.

    Tried removing and redoing, same result..

  6. drted

    You don’t need the mysqladmin -u root password…. step if you set up the root password in the installer.

    on the second command (and subsequent commands in the tutorial), try putting a “sudo” in front of it.

  7. The Geek

    I constantly forget to add sudo before the commands when writing articles… updated.

  8. Atreus

    well you dont need to worry about sudo if you

    sudo su

    when you open your terminal

  9. Atreus

    Oh and I meant to add that your tutorial was very helpful
    a few of the instructions didnt work for me either but then again like previously stated you dont need that line if you already put a password in and I didnt finish that last line but I just used user name as root when i setup amarok and it works great… once again thank you… if it wasnt for people like you then there would be alot of lost people and this operating system wouldnt be as popular as it is now

  10. 1fastbullet

    You know, there are many times when trying to do something in Ubuntu that I come away feeling like a complete dumb-a**. Consequentally, it often pleases me when I see I am not the only one having a hard time with a proceedure.
    This is one of those times.

  11. birre

    >sudo mysqladmin -u root -pMyRootPassword create amarokdb

    I don’t like to type passwords at the command line, even if it’s there so short time that someone can see it only by a miracle.

    How to make it simple:
    create the file /root/.my.cnf and remove rw for others and group.
    touch /root/.my.cnf && chmod go-rw /root/.my.cnf
    Add this:
    host = localhost
    user = root
    password = ‘MyRootPassword’

    Then just do mysqladmin create amarokdb
    But one must do su – , not just su , or change $HOME to /root before calling mysql commands.

  12. Novice

    I have an 80+ gig music collection and it takes Amarok a couple of minutes to load it each time. I found this and was stoked however I end up receiving this “MySQL reported the following error:
    Access denied for user ‘amarok’@’localhost’ (using password: YES)
    You can configure MySQL in the Collection section under Settings->Configure Amarok” from amarok when I try to use the MySQL database. Help please

  13. birre

    To Novice:
    Mysql can be that stupid and refuse the use of password if the user don’t need any, but it can also be a mismatch.
    It should work if you did as the example:
    mysql mysql
    GRANT ALL ON amarokdb.* TO amarok@localhost IDENTIFIED BY ‘amarokpassword’;

    You must flush privileges after a change.

    You can also set the password by hand if you as root run mysql and the database mysql
    mysql mysql
    update user set Password=PASSWORD(‘amarokpassword’) where User=’amarok’;

    Then set the same password in amarok

  14. Newbie

    Worked great and is super nice, thank you

  15. thrashnbash

    This tutorial worked like a champ for me. Appreciate it. Love the work you are doing.

    Just out of curiousity…. do you know a way to cleanup/remove the sqlite db that probably once existed for Amarok? Just looking to thorough and insure Amarok is really looking at my collection via MySQL.


  16. Mike

    Thanks for the tutorial. I’m on Intrepid Ibex (desktop). I have a large music collection but I access it from my Linux server (also Intrepid Ibex). I use SSHFS to do so. I followed all of the instructions, encountered not one problem, yet when I rescan my collection, the results are NOT stored in the database. It takes forever to scan it, but it doesn’t store the results. I did the exact same thing using the SQLite, and it stored all the info about the music, but was SLOW. That’s why this tutorial looked like the perfect fix.

    Any ideas?

  17. thrashnbash

    I noticed the same thing on my system, the results were not stored in the DB. My collection isn’t huge, but its about 45,000 songs. Opening Amarok it was taking me 20 minutes (minimum) until I was able to actually use Amarok. It was just churning through trying to look for updates to my collection.

    As I found out I had not quite followed the instructions to a T. Apparently I had a dumb moment. My username & password were correct. No issues there. I had however not correctly specified the DB name. Instead of specifying amarokdb, I specified it as amarok. Total screw up on my part. Once I went through the steps again I eventually figured it out.

    My original install of Amarok/MySQL was on Hardy Heron. I’ve since moved the DB to a new install of Intrepid (about a month ago). No issues.

    My suggestion (please don’t take offense to it) is just retrace the steps. Make sure you did everything as documented. Make sure the user you created for this DB has access to read/write to the DB, etc… I know its dumb stuff, but we all make mistakes.

  18. Jared

    @ thrashnbash

    To my knowledge the default location for the sqllite database is ~/.kde/share/apps/amarok/collection.db.

  19. Tim

    Wow, does this mean I can use MySQL to tidy up the duplicates in my mp3 collection? Can I use SQL to locate a specific song and send it to a barebones MP3 player?

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!