On the server
Install mysql server, this will ask you to create a password, remember it and keep it safe!
sudo apt-get install mysql-server
Log in to mysql and add the user kodi and give it relevant permissions:
mysql -u root -p CREATE USER 'osmc'@'%' IDENTIFIED BY 'osmc’; GRANT ALL PRIVILEGES on *.* TO 'osmc'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES; \q
Edit the mysql config file to allow access from other devices:
sudo vim /etc/mysql/my.cnf
Fine the line starting ‘bind-address’ and change it to the below, this will allow access from more than localhost
bind-address = 0.0.0.0
Restart the mysql server:
sudo service mysql restart
All done on the server!
On the client(s)
nano ~/.kodi/userdata/advancedsettings.xml
Paste this after replacing XXX.XXX.XXX.XXX with the IP address of the server that you’ve installed mysql-server on:
<advancedsettings>
<videodatabase>
<type>mysql</type>
<host>XXX.XXX.XXX.XXX</host>
<port>3306</port>
<user>osmc</user>
<pass>osmc</pass>
</videodatabase>
<musicdatabase>
<type>mysql</type>
<host>XXX.XXX.XXX.XXX</host>
<port>3306</port>
<user>osmc</user>
<pass>osmc</pass>
</musicdatabase>
<videolibrary>
<importwatchedstate>true</importwatchedstate>
<importresumepoint>true</importresumepoint>
</videolibrary>
</advancedsettings>
Press ctrl + x to save the file.
If this is a second client being connected to the mysql server copy the sources.xml file over, on the client that’s already setup:
scp ~/.kodi/userdata/sources.xml osmc@XXX.XXX.XXX.XXX:~/.kodi/userdata/
Where XXX.XXX.XXX.XXX is the IP address of the device you have just setup to connect to the mysql server.
Done (hopefully)