MySQL/Setting up MySQL: Difference between revisions
< MySQL
Jump to navigation
Jump to search
m (remove misleading unnecessary quotes) |
|||
(15 intermediate revisions by 7 users not shown) | |||
Line 4: | Line 4: | ||
{{-}} | {{-}} | ||
{{redv|'''Please Note:'''| | {{redv|'''Please Note:'''| Do not manually create the MySQL/MariaDB databases on your database server. Set up the MySQL/MariaDB server, and Kodi will create the specific databases for you.}} | ||
{{redv|'''Also:'''| Some versions of MySQL set their passwords to expire by default, '''even the root password'''! If the password expires, Kodi cannot access the database and the TV Series and Movies libraries will disappear.<br /> | {{redv|'''Also:'''| Some versions of MySQL set their passwords to expire by default, '''even the root password'''! If the password expires, Kodi cannot access the database and the TV Series and Movies libraries will disappear.<br /> | ||
To avoid this and/or fix it after it happens, make sure the account's password does not expire. (See: https://dev.mysql.com/doc/refman/5.7/en/password-management.html )}} | To avoid this and/or fix it after it happens, make sure the account's password does not expire. (See: https://dev.mysql.com/doc/refman/5.7/en/password-management.html )}} | ||
MySQL can be installed on just about every major OS: | MySQL/MariaDB can be installed on just about every major OS and NAS: | ||
{{redv|'''Important:'''| Please use only supported versions of the MySQL or MariaDB server. As of January 2019, this is MySQL in at least version 5. | {{redv|'''Important:'''| Please use only supported versions of the MySQL or MariaDB server. As of January 2019, this is MySQL in at least version 5.7 or MariaDB in at least version 5.5, but version 10.3+ is recommended.}} | ||
=Ubuntu Linux= | =Ubuntu Linux= | ||
Line 23: | Line 23: | ||
#When using MySQL8 or higher (Ubuntu 20.04 or later), add the following line at the end of ''/etc/mysql/mysql.conf.d/mysqld.cnf'': | #When using MySQL8 or higher (Ubuntu 20.04 or later), add the following line at the end of ''/etc/mysql/mysql.conf.d/mysqld.cnf'': | ||
##<code>default_authentication_plugin=mysql_native_password</code> | ##<code>default_authentication_plugin=mysql_native_password</code> | ||
##*Note: When using MariaDB this is the default, so you don't need to set it separately | |||
#Restart your MySQL server. <code>sudo service mysql restart</code> | #Restart your MySQL server. <code>sudo service mysql restart</code> | ||
#Get into the MySQL command line utility: <code>mysql -u root -p</code> | #Get into the MySQL command line utility: <code>mysql -u root -p</code> | ||
#Enter the following commands: | #Enter the following commands: | ||
##Type in: <code>CREATE USER 'kodi' IDENTIFIED BY 'kodi';</code> and press return | ##Type in: <code>CREATE USER 'kodi' IDENTIFIED BY 'kodi';</code> and press return | ||
##*Note: | ##*Note: When using MySQL8 or higher, there are additional password requirements and new authentication methods. Using the following command should avoid errors. Type in: <code>CREATE USER 'kodi' IDENTIFIED WITH mysql_native_password BY 'kodi123#';</code> and press return | ||
##*Note: If the above command throws the error <code>ERROR 1064 (42000): You have an error in your SQL syntax;</code> (could happen if using MariaDB 10.5) try this one: <code>CREATE USER 'kodi' IDENTIFIED VIA mysql_native_password USING PASSWORD('kodi123#');</code> and press return | |||
##Type in: <code>GRANT ALL ON *.* TO 'kodi';</code> and press return | ##Type in: <code>GRANT ALL ON *.* TO 'kodi';</code> and press return | ||
##Type in: <code>flush privileges;</code> and press return | ##Type in: <code>flush privileges;</code> and press return | ||
#Close out the command line tool with <code>\q</code> | #Close out the command line tool with <code>\q</code> | ||
=Debian Linux= | |||
'''Debian Linux:''' | |||
#Login as root with <code>$ su -</code> | |||
#<code># apt-get install mariadb-server</code> | |||
#To configure MySQL/MariaDB to listen for connections from network hosts, edit ''/etc/mysql/mariadb.conf.d/50-server.cnf'' and change the bind-address directive to the server's IP address: | |||
##from: <code>bind-address = 127.0.0.1</code> | |||
##to: <code>bind-address = 192.168.0.5</code> | |||
#*Note: Replace 192.168.0.5 with the appropriate address. | |||
#*Note: To allow both local and remote access (i.e. from both the MySQL/MariaDB host to itself and also from other clients), either comment out the bind-address using a hash (#) to disable it, or use <code>bind-address = 0.0.0.0</code> to open it completely. | |||
#Restart your MySQL/MariaDB server. <code># systemctl restart mariadb</code> | |||
#Get into the MySQL command line utility: <code># mysql</code> | |||
#Enter the following commands: | |||
##Type in: <code>CREATE USER 'kodi' IDENTIFIED VIA mysql_native_password USING PASSWORD('kodi123#');</code> and press return | |||
##Type in: <code>GRANT ALL ON *.* TO 'kodi';</code> and press return | |||
##Type in: <code>flush privileges;</code> and press return | |||
#Close out the command line tool with <code>exit</code> or <code>\q</code> | |||
#Logout as root with <code># exit</code> | |||
=Arch Linux= | =Arch Linux= | ||
Line 109: | Line 129: | ||
If you have chocolatey installed run '''choco install mysql''' | If you have chocolatey installed run '''choco install mysql''' | ||
:'''or''' | :'''or''' | ||
#Download a copy of MySQL server from | #Download a copy of MySQL server from https://dev.mysql.com/downloads/windows/installer/8.0.html | ||
#Select '' | #Select ''Archives'' when you want the last stable main version 5.7.36 instead of version 8.0.x. | ||
#Create a password when asked | #Create a password when asked | ||
#Select that you want the database to have network access when prompted during installation. | #Select that you want the database to have network access when prompted during installation. | ||
Line 228: | Line 248: | ||
* <code>flush privileges;</code> | * <code>flush privileges;</code> | ||
* <code>quit;</code> | * <code>quit;</code> | ||
=Docker= | |||
'''Mariadb in Docker Container:''' | |||
If you are new to Docker, first install Docker for your specific OS. Containers are OS independent - see https://www.docker.com/ for more general information about Docker. | |||
If you don't have one already, create a docker-compose.yaml file. | |||
Here's an example service definition for a mariadb container using the offical MariaDB LTS (Long Term Support) image: | |||
services: | |||
mariadb: | |||
image: mariadb:lts | |||
container_name: mariadb | |||
ports: | |||
- 3306:3306 | |||
volumes: | |||
- /your/host/path/to/database/files/:/var/lib/mysql | |||
- /your/host/path/to/mariadb/configuration/files:/config | |||
environment: | |||
- MYSQL_ROOT_PASSWORD=YOUR_MARIADB_ROOT_PASSWORD | |||
- MYSQL_PASSWORD=kodi | |||
- MYSQL_USER=kodi | |||
- MARIADB_AUTO_UPGRADE= | |||
restart: unless-stopped | |||
To bring the new container up, (in folder where docker-compose.yaml is located): | |||
<code>sudo docker compose up -d mariadb</code> | |||
This will create a root user with the password you gave in the Docker Compose file. It will also create a user called "kodi" (please note that you can use any username you want - default is usually "kodi" with a password of "kodi"). The kodi user will NOT have appropriate access until you grant the correct privileges. | |||
So, with the container running: | |||
<code>sudo docker exec -it mariadb bash</code> (to access a shell inside the container). | |||
Then, in that shell, run: | |||
<code>mariadb -u root -p</code> (enter root password from Docker Compose file) | |||
Type: | |||
<code>GRANT ALL PRIVILEGES ON *.* TO 'kodi' IDENTIFIED BY 'kodi' WITH GRANT OPTION;</code> | |||
Then type: | |||
<code>FLUSH PRIVILEGES;</code> | |||
Then you can exit the mariadb shell. | |||
=Restricting MySQL access rights= | =Restricting MySQL access rights= | ||
Line 238: | Line 304: | ||
'''As per MySQL 8.0 Server and upwards:''' | '''As per MySQL 8.0 Server and upwards:''' | ||
#<code>GRANT ALL PRIVILEGES ON `MyVideos%.* | #<code>GRANT ALL PRIVILEGES ON `MyVideos%`.* TO `kodi`@`%`;</code> | ||
#<code>GRANT ALL PRIVILEGES ON `MyMusic%.* | #<code>GRANT ALL PRIVILEGES ON `MyMusic%`.* TO `kodi`@`%`;</code> | ||
{{redv|'''Careful'''|The limited grants on this page don't give the kodi user permissions to create required TRIGGERs during install or upgrade. '''Kodi requires these TRIGGERs to function properly.''' <br /> | {{redv|'''Careful'''|The limited grants on this page don't give the kodi user permissions to create required TRIGGERs during install or upgrade. '''Kodi requires these TRIGGERs to function properly.''' <br /> | ||
Line 245: | Line 311: | ||
Alternatively, figure out how to specifically give the account the right to create the require TRIGGERS - this varies between MySQL versions. }} | Alternatively, figure out how to specifically give the account the right to create the require TRIGGERS - this varies between MySQL versions. }} | ||
<headertabs /> | <headertabs /> | ||
{{Next|[[MySQL/Setting up Kodi|Setting up Kodi]]}} | {{Next|[[MySQL/Setting up Kodi|Setting up Kodi]]}} | ||
{{Isengard updated}} | {{Isengard updated}} |
Latest revision as of 03:54, 31 July 2025
Share libraries w/MySQL, guide: |
![]() |
![]() |
![]() |
You'll need to choose which of your computers, Kodi devices, or NAS will be the MySQL server. The server needs to be on 24/7 or have wake-on-lan (preferably the former), and needs to have a local static IP. You will probably want the Kodi device that is hosting most or all of your videos and music to also be the MySQL server, but this is not required.
Please Note: Do not manually create the MySQL/MariaDB databases on your database server. Set up the MySQL/MariaDB server, and Kodi will create the specific databases for you.
Also: Some versions of MySQL set their passwords to expire by default, even the root password! If the password expires, Kodi cannot access the database and the TV Series and Movies libraries will disappear.
To avoid this and/or fix it after it happens, make sure the account's password does not expire. (See: https://dev.mysql.com/doc/refman/5.7/en/password-management.html )
To avoid this and/or fix it after it happens, make sure the account's password does not expire. (See: https://dev.mysql.com/doc/refman/5.7/en/password-management.html )
MySQL/MariaDB can be installed on just about every major OS and NAS:
Important: Please use only supported versions of the MySQL or MariaDB server. As of January 2019, this is MySQL in at least version 5.7 or MariaDB in at least version 5.5, but version 10.3+ is recommended.
Next step: | Setting up Kodi |