Speed up Amarok with MySQL

Amarok logo So you've got a MySQL database server set up and running and you use Amarok for your music. You'd think those two things are quite separate from each other and wouldn't really combine right?

Now Amarok is a brilliant music jukebox and player and one of its features is that it can use several different types of database to store your music information. One of the database backends it supports is MySQL.

The major benefit of configuring your Amarok to use MySQL instead of the default SQLite is speed. MySQL is a dedicated database system, so if you happen to be running it on your machine anyway (for example if you a have LAMP installation), you may as well take advantage of it.

UPDATE: there is debate as to whether this increases performance or not, but it's still worth a try. YMMV.

A quick word of warning - this process will involve clearing out your current library, meaning you will lose play counts and other metadata (but not any of your music) from your library when it is recreated in MySQL form.

So the first thing we need to do is create a new database for Amarok to store its data and set up a user to give it access. You do this in the standard MySQL way:

$ mysql -u root -p
Password: [[enter MySQL root password]]

Once you're logged in, let's go for it:
mysql> CREATE DATABASE amarok;

Next, let's create a user and give it permissions to the Amarok DB:
mysql> GRANT ALL ON amarok.* TO amarok@localhost IDENTIFIED BY "amarokPassword";

Obviously, you'll want to replace amarokPassword (not including the quotes - keep them wrapped around your password) with a better password of your choice.

Now that's done, we need to open up Amarok, so do that now. Go to Settings > Configure Amarok and click on Collection on the left.

Configure Amarok dialogue box

Select MySQL under Collection Database and enter the username, password and database name that we set up a moment ago. On clicking OK your old collection will disappear and the new one will be built.

If for some reason it won't rebuild automatically, you can manually kick it into action by going to Tools > Rescan Collection.

And there you go - Amarok, powered by MySQL!

Avatar for peter Peter Upfold - http://peter.upfold.org.uk/

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Speed up Amarok with MySQL

  1. Jamey (guest)

    # Posted on 21 October 2007 at 09:22 AM

    SQLite is many orders of magnitude faster than MySQL, are you sure this will make it faster? The only advantage I'm aware of (and reason I personally use the MySQL option) is for networks using the same media library. While there's a few very rare queries where MySQL is faster than SQLite, I find it hard to see Amarok using any of them.

  2. lefty.crupps (guest)

    # Posted on 21 October 2007 at 09:52 AM

    Nice, thank you for the simple HowTo.

    For those who may want to set it up on Kubuntu Gutsy (7.10) -- MySQL installation will prompt you for the MySQL root password. If you've not set up MySQL before, this is the one step you'll be missing from this HowTo, and the system will pretty much do it for you (but you have to provide/create said password).

  3. Chris (guest)

    # Posted on 22 October 2007 at 08:24 AM

    I noticed an EXTRAORDINARY DECREASE in performance doing this. I was very dissapointed, because Amarok seems a little sluggish, even with SQLite.

  4. Charlie (guest)

    # Posted on 23 October 2007 at 04:35 PM

    I've been using Amarok with PostgreSQL for some time on a rubbishy old laptop and the performance is just fine. Can't actually remember why I thought it would be advantageous to do this but at least backing up my library metadata is now a mere matter of running pg_dump.

  5. tim (guest)

    # Posted on 04 November 2007 at 02:52 PM

    I think there is no question that mysql is faster. Before installing it my screen would turn grey after any change to songs in the playlist, now it is instantaneous.

  6. sammael (guest)

    # Posted on 10 November 2007 at 04:30 PM

    same here, switching to mysql immensely sped up amarok. using gutsy

  7. matt (guest)

    # Posted on 25 November 2007 at 11:58 PM

    I've been using sqlite ever since amarok first appeared but as my collection kept growing (to date the numbers are:10718 songs/61GB) it would literally take several (read many) seconds to search for a particular string until the results would come up. I've just made the switch to mysql and it is almost instantaneous, not to mention that scanning/updating the collection really is way faster than used to be with sqlite.

  8. Gabriel (guest)

    # Posted on 28 November 2007 at 10:18 PM

    Does this work with remote music collections? I want to have a separate machine with all my music and the mysql server for amarok. I understand how to set the database on a different machine and tell Amarok to use that, but how will I add/remove files to the collection or how do I tell Amarok that the music files are on another machine? sshfs mount only?

  9. Ramon (guest)

    # Posted on 21 December 2007 at 12:04 PM

    My music collection is over 300full cds stored on my network. I used SQLlite for awhile, it would take a few seconds to switch cds within my collection and if i ever had to reindex it would take about 45 minutes. I switched to mysql for it and every switch no matter how long it has been is instantaneous. Also a reindex of all of my cds takes a few minutes. I'd very happy I switched. For small collections, I'd stay w/ SQLlite

  10. Alexander (guest)

    # Posted on 01 April 2008 at 01:56 AM

    MySql is after my experience WAY faster tham SqlLite when you have a lot (20000+) songs. On small db the difference is not so obvious and maybe there is even SqlLite faster but i recommend everybody to try MySql when the collection crosses 8000-10000 songs.

  11. Rama (guest)

    # Posted on 14 April 2008 at 03:24 PM

    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/

  12. Paul Burton (guest)

    # Posted on 17 April 2008 at 10:22 PM

    Even if it means I have to have MySQL running in the background, having my amarok database run through MySQL is MUCH faster than sqlite, so certainly with a large library (25000+) is really helps

  13. srinath (guest)

    # Posted on 09 October 2008 at 03:47 AM

    buddy thnx for ur valuble solution now my "AMAROK" rocks.........

  14. Regan Wallace (guest)

    # Posted on 13 January 2009 at 02:13 AM

    I never tried to run Amarok with SQLite nor PostgreSQL.

    Why? Because I know MySQL is far faster to search through thousands even hundreds of thousands of rows than SQLite. SQLite is exactly that, 'lite', it's not intended to be a complete database solution, and is more for a quick setup without much headache. PostgreSQL works very nicely for programs that need some of the advanced features of ANSI SQL (like Full Joins, Foreign Keys, etc) but MySQL is intended to be a very fast and responsive database, with the most common features available.

    I have a collection of 77622 songs, at around 570GB. The only thing that seems to be slow, is when I highlight ALL the songs, and right click. As it does a few UGLY SELECT DISTINCT queries, that take quite some time to run. However, I solved the issue by tweaking my my.cnf quite extensively. I have a Desktop with an Amd Athlon 6000+, with 8GB of DDR2 ram, so I gave mysql quite some large numbers for it's query cache, sort/read buffers, sort buffer, key buffer, and adjusted the thread_concurrency. This made Amarok go from waiting 60-70 seconds to bring up the right-click menu, to just 9-10 seconds with the entire collection selected.

    One other nifty feature of using MySQL, is that if you are on a (nix based network, you can use SQL replication (or just a quick bash script with a mysqldump > mysql over ssh), to let networked computers have the statistics, collections and playlists that you setup on the master computer, and just use NFS or Samba to mount the music into the same "path" as it is on the master. (I use /mnt/music, with NFS and MySQL replication; Which on the master is a symlink to it's respective drive, and on the clients, I have it mounted there)

    I've used other players in the past that use SQLite, and they usually fail after about ten thousand songs. But up to that point, SQLite is much faster because it doesn't have the initial overhead a fdatabase solution, like MySQL, has.

    Also, one other tip with MySQL, install PhpMyAdmin and occasionally Optimize Tables on all of Amarok's tables. It goes a long way if your collection changes a lot, and is of a large size like mine. (or just use the mysql cli)

    There's my 2cents

Home » Articles » Speed up Amarok with MySQL