Amarok/Manual/Organization/Collection/ExternalDatabase/da: Difference between revisions

From KDE UserBase Wiki
(Importing a new version from external source)
(Updating to match new version of source page)
Line 15: Line 15:
===== Konfiguration af database =====
===== Konfiguration af database =====


<span class="mw-translate-fuzzy">
Forbind til den lokale database med
Forbind til den lokale database med
{{Input|1=mysql -u root -p}}
{{Input|1=mysql -u root -p}}
Line 29: Line 30:
{{Input|1=exit}}
{{Input|1=exit}}
<br />Som standard kan serveren kun tilgås fra den lokale vært. For at ændre dette skal du redigere filen <tt>/etc/mysql/my.cnf</tt> og tilpasse adressen nær ''bind-address'' til den, som din server lytter til på netværket. '''0.0.0.0''' lytter på alle grænseflader. Efter dette skal du genstarte serveren med
<br />Som standard kan serveren kun tilgås fra den lokale vært. For at ændre dette skal du redigere filen <tt>/etc/mysql/my.cnf</tt> og tilpasse adressen nær ''bind-address'' til den, som din server lytter til på netværket. '''0.0.0.0''' lytter på alle grænseflader. Efter dette skal du genstarte serveren med
{{Input|1=sudo service mysql restart}}
</span>
Create a new user '''''amarokuser''''' with the password '''''amarokpass''''' using the
{{Input|1=CREATE USER '''<nowiki>'</nowiki>amarokuser<nowiki>'</nowiki>'''@'''<nowiki>'</nowiki>localhost<nowiki>'</nowiki>''' IDENTIFIED BY '''<nowiki>'</nowiki>amarokpass<nowiki>'</nowiki>''';}}
command. Amarok needs its own database, which is created with
{{Input|1=CREATE DATABASE '''amarokdb''';}}
Give the new user access to the database by entering the
{{Input|1=GRANT ALL ON '''amarokdb'''.* TO '''<nowiki>'</nowiki>amarokuser<nowiki>'</nowiki>'''@'''<nowiki>'</nowiki>%<nowiki>'</nowiki>''' IDENTIFIED BY '''<nowiki>'</nowiki>amarokpass<nowiki>'</nowiki>''';}}
command, where ''%'' is a wildcard to allow all hosts to connect to the database. Now use the
{{Input|1=FLUSH PRIVILEGES;}}
statement to reload various internal caches used by '''MySQL'''. Finally
{{Input|1=exit}}
closes the '''MySQL''' prompt.
By default the server can only be accessed by the local host. To change this you need to edit the file <tt>/etc/mysql/my.cnf</tt> and adjust the address near ''bind-address'' to the one your server listens on the network. '''0.0.0.0''' listens on all interfaces. After that you need to restart the server using
{{Input|1=sudo service mysql restart}}
{{Input|1=sudo service mysql restart}}


Line 43: Line 60:
Hvis du ønsker at videreføre den statistik osv., som du har i den indlejrede '''MySQL'''-database fra før '''Amarok''' 2.2, så kan du gøre følgende: Start først '''Amarok''' 2.2+ op mindst en gang for at give databasen en chance til at opdatere til den seneste udgave af skemaet.
Hvis du ønsker at videreføre den statistik osv., som du har i den indlejrede '''MySQL'''-database fra før '''Amarok''' 2.2, så kan du gøre følgende: Start først '''Amarok''' 2.2+ op mindst en gang for at give databasen en chance til at opdatere til den seneste udgave af skemaet.


<span class="mw-translate-fuzzy">
Stands derefter den kørende '''MySQL'''-tjeneste med
Stands derefter den kørende '''MySQL'''-tjeneste med
{{Input|1=sudo /etc/init.d/mysql stop}}
{{Input|1=sudo /etc/init.d/mysql stop}}
Line 52: Line 70:
{{Input|1=mysqldump -S sock amarok > amarok.mysql}}
{{Input|1=mysqldump -S sock amarok > amarok.mysql}}
Du kan nu genstarte din '''MySQL'''-tjeneste og indlæse SQL-filen i din '''MySQL'''-server. Du skal allerede have kørt GRANT-kommandoen ovenfor og lavet en database til '''Amarok''' ("CREATE DATABASE amarok;"):
Du kan nu genstarte din '''MySQL'''-tjeneste og indlæse SQL-filen i din '''MySQL'''-server. Du skal allerede have kørt GRANT-kommandoen ovenfor og lavet en database til '''Amarok''' ("CREATE DATABASE amarok;"):
{{Input|1=sudo /etc/init.d/mysql stop
mysql -u amarokuser -p amarok < amarok.mysql}}
</span>
{{Input|1=/usr/sbin/mysqld --defaults-file=`pwd`/my.cnf --default-storage-engine=MyISAM --datadir=`pwd`/mysqle --socket=`pwd`/sock --skip-grant-tables}}
The skip-grant-tables means you can use any password or username to connect to it. 'localhost' will not work, the '''MySQL''' client will try to use a '''Unix''' socket. Using '''127.0.0.1''' as the host makes it work. Some systems may restrict this access through apparmor or SELinux. They can be temporarily disabled with
{{Input|1=sudo /etc/init.d/apparmor stop}}
Now, run mysqldump, passing in the -S option to specify the local socket.  This will dump your old embedded DB out to a SQL file.
{{Input|1=mysqldump -S sock amarok > amarok.mysql}}
You can then restart your '''MySQL''' service and load this SQL file into your '''MySQL''' server. You'll have needed to already run the GRANT statement above and create an '''Amarok''' database ("CREATE DATABASE amarok;"):
{{Input|1=sudo /etc/init.d/mysql stop
{{Input|1=sudo /etc/init.d/mysql stop
mysql -u amarokuser -p amarok < amarok.mysql}}
mysql -u amarokuser -p amarok < amarok.mysql}}

Revision as of 07:16, 1 December 2011

Ekstern database

Amarok 2.2 og senere understøtter en ekstern MySQL-database som motor.

Konfigurering af server
Installation af MySQL-server

Først skal du installere en MySQL-server. På en Debian-baseret distribution som Ubuntu kan du køre

sudo apt-get install mysql-server mysql-client

i en konsol for at installere den. Du vil blive bedt om at angive et password til databasens root-konto. Pakken mysql-client skal bruges til at udføre nogle af kommandoerne i dette dokument, men den er ikke nødvendig for at bruge Amarok.

Konfiguration af database

Forbind til den lokale database med

mysql -u root -p

Du vil blive bedt om passwordet for MySQL's root-bruger. Du vil få promptet

mysql>

Lav en ny bruger, amarokuser med passwordet amarokpass ved at skrive kommandoen

CREATE USER 'amarokuser'@'localhost' IDENTIFIED BY 'amarokpass';

Amarok skal bruge sin egen database, som laves med

CREATE DATABASE amarokdb;

Giv den nye bruger adgang til databasen ved kommandoen

GRANT ALL ON amarokdb.* TO 'amarokuser'@'%' IDENTIFIED BY 'amarokpass';

hvor % er et jokertegn, som lader alle værter forbinde til databasen. Brug nu erklæringen

FLUSH PRIVILEGES;

til at genindlæse diverse interne mellemlagre, som bruges af MySQL. Endelig afsluttes MySQL-promptet med

exit


Som standard kan serveren kun tilgås fra den lokale vært. For at ændre dette skal du redigere filen /etc/mysql/my.cnf og tilpasse adressen nær bind-address til den, som din server lytter til på netværket. 0.0.0.0 lytter på alle grænseflader. Efter dette skal du genstarte serveren med

sudo service mysql restart

Create a new user amarokuser with the password amarokpass using the

CREATE USER 'amarokuser'@'localhost' IDENTIFIED BY 'amarokpass';

command. Amarok needs its own database, which is created with

CREATE DATABASE amarokdb;

Give the new user access to the database by entering the

GRANT ALL ON amarokdb.* TO 'amarokuser'@'%' IDENTIFIED BY 'amarokpass';

command, where % is a wildcard to allow all hosts to connect to the database. Now use the

FLUSH PRIVILEGES;

statement to reload various internal caches used by MySQL. Finally

exit

closes the MySQL prompt.

By default the server can only be accessed by the local host. To change this you need to edit the file /etc/mysql/my.cnf and adjust the address near bind-address to the one your server listens on the network. 0.0.0.0 listens on all interfaces. After that you need to restart the server using

sudo service mysql restart
Konfiguration af klient

Åbn konfigurationsdialogen med menuen Indstillinger -> Indstil Amarok... -> Database. Aktivér valgboksen og angiv brugerdata.



Du skal genstarte Amarok for at ændringerne træder i kraft.

Migration fra indlejret MySQL til MySQL-server

Hvis du ønsker at videreføre den statistik osv., som du har i den indlejrede MySQL-database fra før Amarok 2.2, så kan du gøre følgende: Start først Amarok 2.2+ op mindst en gang for at give databasen en chance til at opdatere til den seneste udgave af skemaet.

Stands derefter den kørende MySQL-tjeneste med

sudo /etc/init.d/mysql stop

og start en MySQL-dæmon fra din mappe ~/.kde4/share/apps/amarok (--defaults-file SKAL være det første tilvalg):

/usr/sbin/mysqld --defaults-file=`pwd`/my.cnf --default-storage-engine=MyISAM --datadir=`pwd`/mysqle --socket=`pwd`/sock --skip-grant-tables

Tilvalget skip-grant-tables betyder, at du kan bruge et hvilket som helst password og brugernavn til at forbinde til den. 'localhost' vil ikke fungere, MySQL-klienten vil så prøve at bruge en Unix-socket. Brug 127.0.0.1 som vært får det til at fungere. Nogle systemer begrænser denne adgang med apparmor eller SELinux. De kan slås fra midlertidigt med

sudo /etc/init.d/apparmor stop

Kør nu mysqldump med tilvalget -S for at specificere den lokale vært. Dette vil dumpe din gamle indlejrede database ud til en SQL-fil.

mysqldump -S sock amarok > amarok.mysql

Du kan nu genstarte din MySQL-tjeneste og indlæse SQL-filen i din MySQL-server. Du skal allerede have kørt GRANT-kommandoen ovenfor og lavet en database til Amarok ("CREATE DATABASE amarok;"):

sudo /etc/init.d/mysql stop
mysql -u amarokuser -p amarok < amarok.mysql

/usr/sbin/mysqld --defaults-file=`pwd`/my.cnf --default-storage-engine=MyISAM --datadir=`pwd`/mysqle --socket=`pwd`/sock --skip-grant-tables

The skip-grant-tables means you can use any password or username to connect to it. 'localhost' will not work, the MySQL client will try to use a Unix socket. Using 127.0.0.1 as the host makes it work. Some systems may restrict this access through apparmor or SELinux. They can be temporarily disabled with

sudo /etc/init.d/apparmor stop

Now, run mysqldump, passing in the -S option to specify the local socket. This will dump your old embedded DB out to a SQL file.

mysqldump -S sock amarok > amarok.mysql

You can then restart your MySQL service and load this SQL file into your MySQL server. You'll have needed to already run the GRANT statement above and create an Amarok database ("CREATE DATABASE amarok;"):

sudo /etc/init.d/mysql stop
mysql -u amarokuser -p amarok < amarok.mysql

Note

Du skal måske genscanne din samling i Amarok efter at have gjort dette.