You are not logged in.

#1 2007-12-17 04:10:27

fluxme
Member
Registered: 2007-12-05
Posts: 36

Fails to create MPD-database

Hello,

I'm trying to setup mpd with Sonata.
I'm following the Arch-wiki and the mpd-wiki on this topic,
It seems I'm having some problems with my configuration-files.

According to the Arch-wiki I should execute the following command to create the database

/etc/rc.d/mpd create-db

If I execute it without sudo I get the following message

/etc/rc.d/mpd: line 30: /var/log/mpd/mpd.db-creation: Permission denied

If I execute the command as root I end up with this message

cannot open playlist_directory "/root/.mpd/playlists/" (config line 3): No such file or directory

I have created both a /etc/mpd.conf and a ~/.mpdconf .
Both are identical and look like this

port                 "6600"
music_directory         "/media/sda1/Downloads"
playlist_directory        "~/.mpd/playlists"
db_file              "~/.mpd/mpd.db"
log_file            "~/.mpd/mpd.log"
error_file            "~/.mpd/mpd.error"

Hope some of you is able to figure it out.

Fluxme

Offline

#2 2007-12-17 04:33:17

K2712
Member
From: Greenville, SC
Registered: 2006-05-17
Posts: 28

Re: Fails to create MPD-database

In your conf files there is a 'user' line that you need to change to your username.

In my file it was line 46 and looked like:

user                            "mpd"

Just change "mpd" to "your-username", and reload the mpd daemon and you should be good to go.

Offline

#3 2007-12-17 04:35:29

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Fails to create MPD-database

The first error is a permission issue - your user has no writing privileges in /var/log/mpd.  The second error (when you run the command as root) is because mpd translates all "~/" from the config file as the home dir of the user that's executing the command (which, is /root if you're executing the command as root).  The easiest solution is to chown /var/log/mpd as your user.  Alternatively (and this is what I do) you can have something like this in your /etc/mpd.conf instead:

music_directory                 "[your music dir here]"
playlist_directory              "/var/lib/mpd/playlists"
db_file                         "/var/lib/mpd/mpd.db"
log_file                        "/var/log/mpd/mpd.log"
error_file                      "/var/log/mpd/mpd.error"

In which case you can to chown /var/log/mpd as mpd:mpd and comment out the user line in /etc/mpd.conf.

I hope that makes sense.

Last edited by fwojciec (2007-12-17 04:36:02)

Offline

#4 2007-12-17 08:56:16

RhahkJin
Member
From: Tübingen, Germany
Registered: 2007-12-05
Posts: 13

Re: Fails to create MPD-database

fwojciec wrote:

In which case you can to chown /var/log/mpd as mpd:mpd and comment out the user line in /etc/mpd.conf.

I don't think this an good idea..
Commenting out the user line in mpd.conf forces mpd to not fall back to user mode -> it runs as root all the time (And You don't want to have daemon with an port open to run in root-mode).

If /var/log/mpd and /var/lib/mpd (in your example) is owned by user mpd, the user line in mpd.conf could stay as it is (user "mpd") and it should work.

Offline

#5 2007-12-17 13:52:32

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Fails to create MPD-database

RhahkJin wrote:
fwojciec wrote:

In which case you can to chown /var/log/mpd as mpd:mpd and comment out the user line in /etc/mpd.conf.

I don't think this an good idea..
Commenting out the user line in mpd.conf forces mpd to not fall back to user mode -> it runs as root all the time (And You don't want to have daemon with an port open to run in root-mode).

If /var/log/mpd and /var/lib/mpd (in your example) is owned by user mpd, the user line in mpd.conf could stay as it is (user "mpd") and it should work.

Yes, you're right.  I guess I've misread the comment in the conf file - I thought it would drop root privileges regardless...  Thanks for pointing this out.

Offline

#6 2007-12-18 02:19:26

fluxme
Member
Registered: 2007-12-05
Posts: 36

Re: Fails to create MPD-database

Thanks for all the answers. I tried K2712's approach since it seemed to be the easiest solution. By the way, is there any downside to not using fwojciec's method?

The first solution worked fine. I created the database, allthough I didn't see a [DONE], but rather an empty pair of brackets.
Then I tried to start up mpd, using sudo /etc/rc.d/mpd start
as stated in the wiki. Unfortunately it fails and I don't have the slightest idea why. Allthough there's probably something wrong with my config-file.
Actually I have two files. Don't know if it matters, but I created the ~/.mpdconf also.

/etc/mpd.conf

# An example configuration file for MPD
# See the mpd.conf man page for a more detailed description of each parameter.

######################## REQUIRED PATHS ########################
music_directory                 "/media/sda1/Downloads"
playlist_directory              "~/playlists"
db_file                         "~/mpd.db"
log_file                        "~/mpd.log"
error_file                      "~/mpd.error"

#music_directory                 "path_to_your_music_collection"
#playlist_directory              "/var/lib/mpd/playlists"
#db_file                         "/var/lib/mpd/mpd.db"
#log_file                        "/var/log/mpd/mpd.log"
#error_file                      "/var/log/mpd/mpd.error"

# Note: ~ is the home directory of user set in the "user" option
################################################################


######################## OPTIONAL PATHS ########################
#
# If you wish to use mpd --kill to stop MPD, then you must
# specify a file here in which to store MPD's process ID.
#
#pid_file                        "~/.mpd/mpd.pid"
pid_file                        "/var/run/mpd/mpd.pid"
#
# If specified, MPD will save its current state (playlist,
# current song, playing/paused, etc.) at exit.  This will be
# used to restore the session the next time it is run.
#
#state_file                      "~/.mpd/mpdstate"
state_file                      "/var/lib/mpd/mpdstate"
#
################################################################


######################## DAEMON OPTIONS ########################
#
# If started as root, MPD will drop root privileges and run as
# this user instead.  Otherwise, MPD will run as the user it was
# started by.  If left unspecified, MPD will not drop root
# privileges at all (not recommended).

user                            "daniel"

# The address and port to listen on.
#
bind_to_address                 "192.168.178.1"
#bind_to_address                 "any"
#port                            "6600"
#
# Controls the amount of information that is logged.  Can be
# "default", "secure", or "verbose".
#
#log_level                       "default"
#
################################################################


########################## PERMISSIONS #########################
#
# MPD can require that users specify a password before using it.
# You may specify one ore more here, along with what users who
# log in with that password are allowed to do.
#
#password                        "password@read,add,control,admin"
#
# Specifies what permissions a user who has not logged in with a
# password has.  By default, all users have full access to MPD
# if no password is specified above, or no access if one or
# more passwords are specified.
#
#default_permissions             "read,add,control,admin"
#
################################################################


########################## AUDIO OUTPUT ########################
#
# MPD supports many audio output types, as well as playing
# through multiple audio outputs at the same time.  You can
# specify one or more here.  If you don't specify any, MPD will
# automatically scan for a usable audio output.
#
# See <http://mpd.wikia.com/wiki/Configuration#Audio_Outputs>
# for examples of other audio outputs.
#
# An example of an ALSA output:
#
#audio_output {
#        type                    "alsa"
#        name                    "My ALSA Device"
#        device                  "hw:0,0"     # optional
#        format                  "44100:16:2" # optional
#}
#
# An example of an OSS output:
#
#audio_output {
#        type                    "oss"
#        name                    "My OSS Device"
#        device                  "/dev/dsp"   # optional
#        format                  "44100:16:2" # optional
#}
#
# An example of a shout output (for streaming to Icecast):
#
#audio_output {
#        type                    "shout"
#        name                    "My Shout Stream"
#        host                    "localhost"
#        port                    "8000"
#        mount                   "/mpd.ogg"
#        password                "hackme"
#        quality                 "5.0"
#        bitrate                 "128"
#        format                  "44100:16:1"
#        user                    "source"                # optional
#        description             "My Stream Description" # optional
#        genre                   "jazz"                  # optional
#        public                  "no"                    # optional
#}
#
# Force all decoded audio to be converted to this format before
# being passed to the audio outputs.
#
#audio_output_format             "44100:16:2"
#
################################################################


############################# MIXER ############################
#
# MPD needs to know what mixer settings to change when you
# adjust the volume.  If you don't specify one here, MPD will
# pick one based on which ones it was compiled with support for.
#
# An example for controlling an ALSA mixer:
#
#mixer_type                      "alsa"
#mixer_device                    "default"
#mixer_control                   "PCM"
#
# An example for controlling an OSS mixer:
#
#mixer_type                      "oss"
#mixer_device                    "/dev/mixer"
#mixer_control                   "PCM"
#
# If you want MPD to adjust the volume of audio sent to the
# audio outputs, you can tell it to use the software mixer:
#
#mixer_type                      "software"
#
################################################################


######################### NORMALIZATION ########################
#
# Specifies the type of ReplayGain to use.  Can be "album" or
# "track".  ReplayGain will not be used if not specified.  See
# <http://www.replaygain.org> for more details.
#
#replaygain                      "album"
#
# Sets the pre-amp used for files that have ReplayGain tags.
#
#replaygain_preamp               "0"
#
# Enable on the fly volume normalization.  This will cause the
# volume of all songs played to be adjusted so that they sound
# as though they are of equal loudness.
#
#volume_normalization            "no"
#
################################################################


########################### BUFFERING ##########################
#
# The size of the buffer containing decoded audio.  You probably
# shouldn't change this.
#
#audio_buffer_size               "2048"
#
# How much of the buffer to fill before beginning to play.
#
#buffer_before_play              "0%"
#
# Similar options for the HTTP stream buffer.  If you hear
# skipping while playing HTTP streams, you may wish to increase
# these.
#
#http_buffer_size                "128"
#http_prebuffer_size             "25%"
#
################################################################


########################### HTTP PROXY #########################
#
# Specifies the HTTP proxy to use for playing HTTP streams.
#
#http_proxy_host                 "proxy.isp.com"
#http_proxy_port                 "8080"
#http_proxy_user                 "user"
#http_proxy_password             "password"
#
################################################################


############################# LIMITS ###########################
#
# These are various limits to prevent MPD from using too many
# resources.  You should only change them if they start
# restricting your usage of MPD.
#
#connection_timeout              "60"
#max_connections                 "5"
#max_playlist_length             "16384"
#max_command_list_size           "2048"
#max_output_buffer_size          "8192"
#
################################################################


###################### CHARACTER ENCODINGS #####################
#
# If file or directory names do not display correctly, then you
# may need to change this.  In most cases it should be either
# "ISO-8859-1" or "UTF-8".  You must recreate your database
# after changing this (use mpd --create-db).
#
#filesystem_charset              "ISO-8859-1"
#
# The encoding that ID3v1 tags should be converted from.
#
#id3v1_encoding                  "ISO-8859-1"
#
################################################################


######################### OTHER OPTIONS ########################
#
# The metadata types MPD will recognize.
#
#metadata_to_use                  "artist,album,title,track,name,genre,date,composer,performer,disc"
#
# Enable this if you wish to use your MPD created playlists in
# other music players.
#
#save_absolute_paths_in_playlists "no"
#
################################################################

~/.mpdconf

port                "6600"
music_directory         "/media/sda1/Downloads"
playlist_directory        "~/playlists"
db_file              "~/.mpd/mpd.db"
log_file            "~/.mpd/mpd.log"
error_file            "~/.mpd/mpd.error"

user                "daniel"

Thanks for helping me out smile

Offline

#7 2007-12-18 04:56:44

K2712
Member
From: Greenville, SC
Registered: 2006-05-17
Posts: 28

Re: Fails to create MPD-database

What is the output of:

mpd --verbose

Offline

#8 2007-12-18 08:12:37

tami
Member
From: Norway, Oslo
Registered: 2007-11-10
Posts: 58
Website

Re: Fails to create MPD-database

Hi fluxme,

First of - I'm a newbie to Arch but I'm not so new to mpd wink

I'm using this great daemon for quite a long time on different machines and using different distributions - also on Arch.

So, let me share my experience with you.

1. For the first: I have only one configuration file of mpd here on Arch - this at home. I would advise you to move /etc/mpd.conf to /etc/mpd.conf.example.

# mv /etc/mpd.conf /etc/mpd.conf.example

2. Then I would copy the original configuration file (now - /etc/mpd.conf.example) into my home directory  and I would edit it. In your case it should be probably something like this:

$ cp /etc/mpd.conf.example /home/daniel/.mpdconf

3. You took good first steps in creating your .mpdconf file:
   

port                "6600"
music_directory         "/media/sda1/Downloads"
playlist_directory        "~/playlists"
db_file              "~/.mpd/mpd.db"
log_file            "~/.mpd/mpd.log"
error_file            "~/.mpd/mpd.error"

user                "daniel"

Just change the appropriate lines in copied file. In my configuration file I added the line:

pid_file         "/home/tami/.mpd/mpd.pid"

to the required part of .mpdconf. (just change tami -> daniel)

I hope also that you created the .mpd directory at your home.

$ mkdir /home/daniel/.mpd

4. But it seems it's not enough. You should also uncomment and edit the lines concerning Mixer.
For instance - if you use alsa you should uncomment and edit it like this:

# ALSA Mixer
mixer_type "alsa"
mixer_device "default"
mixer_control "PCM"

Then I simply run:

$ mpd --create-db

as a normal user and then also simply:

$ mpd

You can add mpd to crontab afterwards or add it to your deamons (I prefer the first solution).

I hope it will help you and sorry if it was too detailed but from my experience - the most irritating mistakes occur when you omit the small step.
...at least the above steps work in my case. (I just hope I did not omit something wink )

Best wishes to you and all fantastic Arch Community,

tami smile

(very new but very glad Arch user)


"Possession means worries and luggage bags one has to drag along." Little My wink

Offline

Board footer

Powered by FluxBB