./admin/InitDb.pl --createdb --clean - creating the DB

virtualbox
musicbrainz-vm
Tags: #<Tag:0x00007f23c15b2688> #<Tag:0x00007f23c15b2548>

#1

Hi,

I am hoping someone can help, when creating the database for MusicBrainz clean install i get peer authentication. i am hoping for some guidance on this.

musicbrainz@musicbrainz-VirtualBox:~/musicbrainz-server$ ./admin/InitDb.pl --createdb --clean
Failed query:
‘SELECT current_setting(‘server_version_num’)’
()
08006 DBI connect(‘dbname=template1’,‘postgres’,…) failed: FATAL: Peer authentication failed for user "postgres"
at /home/musicbrainz/musicbrainz-server/admin/…/lib/Sql.pm line 460.
Sql::catch {…} (MusicBrainz::Server::Exceptions::DatabaseError=HASH(0x2524238)) called at /usr/share/perl5/Try/Tiny.pm line 115
Try::Tiny::try(CODE(0x1cafb68), Try::Tiny::Catch=REF(0x24309e0), Try::Tiny::Finally=REF(0xee0768)) called at /home/musicbrainz/musicbrainz-server/admin/…/lib/Sql.pm line 466
Sql::_select_list(Sql=HASH(0x1ca3f60), “SELECT current_setting(‘server_version_num’)”, ARRAY(0x22e92d8), “arrayref”, CODE(0x22e91e8)) called at /home/musicbrainz/musicbrainz-server/admin/…/lib/Sql.pm line 485
Sql::select_list_of_lists(Sql=HASH(0x1ca3f60), “SELECT current_setting(‘server_version_num’)”) called at /home/musicbrainz/musicbrainz-server/admin/…/lib/Sql.pm line 416
Sql::select_single_column_array(Sql=HASH(0x1ca3f60), “SELECT current_setting(‘server_version_num’)”) called at /home/musicbrainz/musicbrainz-server/admin/…/lib/Sql.pm line 431
Sql::select_single_value(Sql=HASH(0x1ca3f60), “SELECT current_setting(‘server_version_num’)”) called at ./admin/InitDb.pl line 73
main::RequireMinimumPostgreSQLVersion() called at ./admin/InitDb.pl line 517
08006 DBI connect(‘dbname=template1’,‘postgres’,…) failed: FATAL: Peer authen


#2

I’ve been getting a similar error, i can install all the dependencies - but i am unable to run the InitDB.Pl script

Failed Query: ‘SELECT current_settings(‘server_version_num’)’
()

I am wondering if the PSQL version is not reporting the same anymore (hopefully someone can answer this?) and the InitDB.pl script needs to be rewritten to work with that?

my question was moved to the dev section and has had no further response.


#3

Have you set up peer authentication for the musicbrainz OS user?
This would allow you to login to the database as the administrator without specifying a username and password.

The postgres os user has this set up so if you run InitDb.pl it will connect to the database as the administrator user.

From memory you can specify a username, password, hostname and port when running InitDB.pl and setting up the database.


#4

Thanks, I will try that and give you feedback, thanks for the help on this.

-MB


#5

I’m having the same issue. I’d appreciate if someone could further explain the solution to that.
Thanks


#6

I have the same problem.

I guess you mean the entries to pg_hba.conf and pg_ident.conf. Yes I did, although the INSTALL.md says Note: The order of lines is important! without specifying, what order. The default pg_hba.conf comes with some entries. So where does the line I have to add has to be placed, at the end or the beginning? I tried both without success.

So I have an OS user musicbrainz, which I assume is also the www-user since he starts plackup -Ilib -r later.

My pg_hba.conf looks like this

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

local    musicbrainz_db    musicbrainz    ident    map=mb_map

and pg_ident.conf contains this line
mb_map musicbrainz musicbrainz

But when I run
~/musicbrainz-server$ ./admin/InitDb.pl --createdb --import ../mbdump*.tar.bz2 --echo
I’m getting

Failed query:
        'SELECT current_setting('server_version_num')'
        ()
08006 DBI connect('dbname=template1','postgres',...) failed: FATAL:  Peer authentication failed for user "postgres"
 at /home/musicbrainz/musicbrainz-server/admin/../lib/Sql.pm line 460.
        Sql::catch {...} (MusicBrainz::Server::Exceptions::DatabaseError=HASH(0x230dfd8)) called at /usr/share/perl5/Try/Tiny.pm line 115
        Try::Tiny::try(CODE(0x1a97398), Try::Tiny::Catch=REF(0x2217758), Try::Tiny::Finally=REF(0xcbe7a8)) called at /home/musicbrainz/musicbrainz-server/admin/../lib/Sql.pm line 466
        Sql::_select_list(Sql=HASH(0x1a8b798), "SELECT current_setting('server_version_num')", ARRAY(0x20d1320), "arrayref", CODE(0x20d1230)) called at /home/musicbrainz/musicbrainz-server/admin/../lib/Sql.pm line 485
        Sql::select_list_of_lists(Sql=HASH(0x1a8b798), "SELECT current_setting('server_version_num')") called at /home/musicbrainz/musicbrainz-server/admin/../lib/Sql.pm line 416
        Sql::select_single_column_array(Sql=HASH(0x1a8b798), "SELECT current_setting('server_version_num')") called at /home/musicbrainz/musicbrainz-server/admin/../lib/Sql.pm line 431
        Sql::select_single_value(Sql=HASH(0x1a8b798), "SELECT current_setting('server_version_num')") called at ./admin/InitDb.pl line 73
        main::RequireMinimumPostgreSQLVersion() called at ./admin/InitDb.pl line 518
08006 DBI connect('dbname=template1','postgres',...) failed: FATAL:  Peer authentication failed for user "postgres"

#7

You need to create a musicbrainz postgres user.
Login as the postgres os account with sudo and use the createuser command.
sudo su - postgres
createuser -s musicbrainz

Note this needs to be a superuser when you create the database so you need the -s.
I would revoke this once you are done creating the database,


#8

I already created the database user musicbrainz, but not as superuser. Why is none of this written in the documentation? :unamused:

createuser -s musicbrainz doesn’t ask for a password. Is this correct? Either way, with or without password set to ‘musicbrainz’ I got the same error.

I purged postgresql and started over. Now I put local all all trust at the beginning of pg_hba.conf, restarted postgresql and now it started importing the db_dump. I got a few errors
Error loading /tmp/MBImport-QjFqPM6y/mbdump/tag: 22001 DBD::Pg::db pg_putcopyend failed: ERROR: value too long for type character varying(255)

all of them have some chinese or arabic characters in the column comment.
I also got some errors
No data file found for 'alternative_medium', skipping
which I guess are for the dumps I didn’t downloaded.

At the end of the import it says
Mon May 29 13:34:24 2017 : ensuring editor information is present
Mon May 29 13:34:25 2017 : import finished
Loaded 186 tables (107844696 rows) in 677 seconds

Failed to import dataset.
Mon May 29 13:34:26 2017 : InitDb.pl failed

Is it safe to ignore these errors? I’m asking, because I can’t access the web page after running
plackup -Ilib -r

But for this I will open a new thread.


#9

Hi,
There’s a known error in one of the versions of the libraries that we’re using in the musicbrainz server.
We’re working on a solution, but until then you can manually install a different version by running

cpanm TURNSTEP/DBD-Pg-3.5.3.tar.gz

(From step 7 at https://blog.musicbrainz.org/2017/05/16/schema-change-release-2017-05-15-including-upgrade-instructions/)

You should be able to perform the import after this.

It’s not a problem that you get the messages for No data file found for 'alternative_medium', skipping, you’re correct that they appear because you didn’t download the data files for these tables.


#10

Actually, I’m pretty sure the alternative_medium one is specifically because there are still no “alternative mediums” in the database at all, as we’re waiting on a UI to add/edit those (they’ve been part of the database since the 2016 schema change, but for a number of reasons, there haven’t been resources available to finalise this).

See May 2016 schema change release details and MBS-4501: Alternative tracklists (and maybe even musicbrainz-server PR #280) for more information.