Guide to install a MySQL DB server on the AFTV. This setup has been working great to share my Kodi DB between several devices. It may also work for other Android devices, but I haven’t tested them. Based on the description found in http://www.thaivisa.com/forum/topic/8093…etv-boxes/
Disclaimer: I have no association with KSWEB. I only purchased their package to make the installation easier.
My setup was done using a rooted AFTV (2nd gen) running v5.2.1.0 (Build 550145120), and Jarvis (SPMC 16.4.2).
Prerequisites:
- Ensure the AFTV has a fixed IP. You’ll need to the IP address, device id (Settings->System->About).
- You’ll also need a mouse and a keyboard, ideally connected to the AFTV via a USB hub
- Export your Kodi library if you want to import this in MySQL later on (using the Settings menu in Kodi), see also Import-export_library. (wiki) Export to multiple files, no need to export the artwork.
- Root access is not required
Installation:
- Download the apk of the KSWEB server suite for sideloading from http://kslabs.ru/ I used v3.62
- Buy a KSWEB serial key (US$2.99). You’ll get an email with the key linked to a Play store account. Then send your device id to them and ask them to link your key to the device.
- Sideload the KSWEB apk using adblink
- Start KSWEB and enter the license key in the GUI (you’ll need to attach a mouse / keyboard to navigate / enter this)
- Select Auto Start in the Settings menu to automatically start KSWEB after a reboot. Check that the mysqld is running using an adb shell and commands ‘ps | grep mysql’, or ‘netstat -an | grep 3306’. You should see a process that LISTENs on port 3306
- Replace the my.ini MySQL config file in /data/data/ru.kslabs.ksweb/components/mysql/conf with this content:
## !!!WARNING!!!
## Be careful changing this configuration file!
## Some changes may result in incorrect function of the program.
## Always make backups of configuration files before any changes.
## ————————————————————–
[client]
port=3306
socket=/data/data/ru.kslabs.ksweb/tmp/mysql.sock
character-sets-dir=/data/data/ru.kslabs.ksweb/components/mysql/sbin/share/charsets/
[mysql]
character-set-server=utf8
[mysqld]
log-error=/mnt/sdcard/ksweb/log/mysql/mysql.log
bind-addr=0.0.0.0
port=3306
socket=/data/data/ru.kslabs.ksweb/tmp/mysql.sock
character-sets-dir=/data/data/ru.kslabs.ksweb/components/mysql/sbin/share/charsets/
basedir=”/data/data/ru.kslabs.ksweb/components/mysql/sbin/”#begin_datadir (do not remove this label!)
datadir=”/data/data/ru.kslabs.ksweb/components/mysql/sbin/data”
#end_datadir (do not remove this label!)tmpdir =”/data/data/ru.kslabs.ksweb/tmp”
character-set-server=utf8
max_allowed_packet = 16M
performance_schema = off#default-storage-engine=myisam
default_storage_engine=InnoDBmax_connections=10
innodb_buffer_pool_size=20M
innodb_log_buffer_size=2M
innodb_additional_mem_pool_size=2M
innodb_ft_cache_size=1600000
innodb_ft_total_cache_size=32000000
query_cache_size=1M
query_cache_type=0
thread_cache_size=0
key_buffer_size=1M
innodb_file_per_table=1
innodb_log_file_size=5M# per thread or per operation settings
thread_stack=192K
sort_buffer_size=512K
read_buffer_size=128K
read_rnd_buffer_size=256K
max_heap_table_size=128K
tmp_table_size=1M
bulk_insert_buffer_size=0
join_buffer_size=128K
innodb_sort_buffer_size=1M
- I did this using an adb shell (‘cat > my.ini’ <PASTE> ^D), but you can easily upload the file using adblink. Restart MySQL
- Make sure the lighttpd and PHP services are up and running. Install PHPMyAdmin from the KSWEB Tools menu.
- Open PHPMyAdmin on your favorite device in your favorite browser using the IP of your AFTV and the port shown in the Status page of KSWEB (e.g. http://192.168.1.200:8002). Login: root/<none>. You should change this password using PHPMyAdmin
- Once in PHPMyAdmin -> Users tab, Add user.. Choose username (kodi) pass (kodi) and leave it it for ‘any host’ access. Do not check to create a database, this will be done by Kodi later. In the same dialogue, make sure user kodi is granted access rights to Create databases
- In Kodi, go to Settings->Services->MySQL and enter the AFTV IP, username (kodi) and password (kodi). Then select Enable to use MySQL.
- If your sources contain SMB shares, ensure these are linked via IP and not WINS name (e.g. smb://192.168.1.100/myshare/movies). If they are not, correct this. Then rescan your sources. Kodi will import previously exported data.
Repeat the last two steps to link other Kodi installations to the MySQL database. No need to rescan sources, unless they use different sources.
- Optional: If Kodi starts up automatically upon boot (this probably requires root), you can have it wait for the MySQL DB server to be ready. (see also Wake_on_lan (wiki))
Enable wake-on-lan under Settings → System → Power saving → Try to wake remote servers on access
Replace the content of the wakeonlan.xml file that is stored in the userdata folder of Kodi with the below content. Make sure to replace YOUR IP and YOUR MAC with the correct values:
<onaccesswakeup>
<netinittimeout>20</netinittimeout>
<netsettletime>500</netsettletime>
<wakeup>
<host>YOUR IP</host>
<mac>YOUR MAC</mac>
<pingport>3306</pingport>
<pingmode>1</pingmode>
<timeout>300</timeout>
<waitonline>40</waitonline>
<waitonline2>40</waitonline2>
<waitservices>5</waitservices>
</wakeup>
</onaccesswakeup>
- Optional: You may want to change the lighttpd password (defaults to admin/admin). This is listening on a port as per Status page of KSWEB, likely port 8001.
- Optional: Once all is working to your satisfaction, you can disable lighttpd and PHP in the KSWEB console and also select to start KSWEB minimized (see Settings).