Difference between revisions of "Database Setup"

From MythTV Official Wiki
Jump to: navigation, search
(Created page with "{{User Manual TOC}} {{UpToDate 0.27}} ==MySQL== You will want to comment out any "log-bin" or "log_bin" lines in your my.cnf configuration file. This option will quickly fil...")
 
(Additions for mariadb .cnf file)
Line 97: Line 97:
 
</pre>
 
</pre>
 
By doing the above, if the mysql package manager changes ''my.cnf'', then local changes won't be overwritten.
 
By doing the above, if the mysql package manager changes ''my.cnf'', then local changes won't be overwritten.
 +
 +
''mariadb'' users should use the same concept. However, be sure to check ''/etc/mysql/my.cnf'' first
 +
to see the order of the files it includes. One example is:
 +
<pre>
 +
!includedir /etc/mysql/conf.d/
 +
!includedir /etc/mysql/mariadb.conf.d/
 +
</pre>
 +
That means that changes make in the 'old' ''conf.d'' directory could be overwritten by
 +
changes in ''mariadb.conf.d''. Also note that the individual ''.cnf'' files are parsed
 +
alphabetically. Since ''/etc/mysql/mariadb.conf.d/mysql.cnf'' contains a setting for
 +
''bind-address'', overriding it must be done in a file alphabetically greater
 +
than it. ''/etc/mysql/mariadb.conf.d/mythtv.cnf'' will work fine in this case. Just
 +
be sure that there aren't any other ''.cnf'' files that would override it's changes.
  
 
[[Category:Advanced Topics]]
 
[[Category:Advanced Topics]]

Revision as of 19:46, 2 January 2016


Software-update-available.png This page is up-to-date as of MythTV version 0.27.6, the current release is 34.0

MySQL

You will want to comment out any "log-bin" or "log_bin" lines in your my.cnf configuration file. This option will quickly fill your "/var" disk partition with many gigabytes of data, unless you are doing database replication and deleting these files regularly.

Distribution-specific information

Red Hat Linux and Fedora

If this is the system maintaining the database, make sure that MySQL is running and started at boot. Click on Redhat menu>Server Settings>Services and enter the root password when asked. Check "mysqld" and then click Start. Click Save, then close the window.

This can be done from the command line by typing:

# /sbin/chkconfig mysqld on
# /sbin/service mysqld start

With recent 2014 changes in Fedora 19/20 and RHEL/CentOS7 systemd has repalced SysV for service maintenance. The mariadb has also replaced mysql as default db handler although it responds to all mysql calls as well. The "newer" commands for doing this from the command line are as follows:

to have the service start at boot
# systemctl enable mariadb.service
or the longer version of this command
# ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
and then to start the service right now
# systemctl start mariadb.service
Finally to confirm the service is running the command is
# systemctl status mariadb.service

Setting up the initial database

This step is only required on the system maintaining the database, which may or may not be one of your MythTV boxes. If the database is on a non-MythTV machine you'll need to copy the database/mc.sql file to it.

To setup the initial MySQL databases: $ cd database

Mandriva and Red Hat Linux/Fedora Core

$ mysql -u root < mc.sql

Debian

$ mysql < mc.sql

Gentoo

$ su
# mysql < /usr/share/mythtv/database/mc.sql

HOWTO-Stop.png NOTE: It is good practice to set a root password for MySQL. Instructions for doing so can be found on MySQL's web site at http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html

Modifying access to the MySQL database for multiple systems

If you're going to have multiple systems accessing a master database, you must grant access to the database from remote systems. By default, the mc.sql script is only granting access to the local host.

To allow other hosts access to your master database, you can either configure MySQL database access with no security or with additional granularity.

HOWTO-Stop.png NOTE: The "no security" option is very dangerous unless you're in a controlled environment.

The "%" is the wildcard character in MySQL.

This example has no security at all, and allows access from any host.

$ mysql -u root mythconverg
mysql> grant all on mythconverg.* to mythtv@"%" identified by "mythtv";
mysql> flush privileges;

For a more secure setup, you can restrict which machines or subnets have access. If you have a complete DNS system operational, you could do the following:

$ mysql -u root mythconverg
mysql> grant all on mythconverg.* to mythtv@"%.mydomain.com" identified by "mythtv";
mysql> flush privileges;

Finally, if you just want to restrict by IP subnet (in this example, the 192.168.1. network):

$ mysql -u root mythconverg
mysql> grant all on mythconverg.* to mythtv@"192.168.1.%" identified by "mythtv";
mysql> flush privileges;

You'll also need to check that the "networking" feature of MySQL is turned on. Check that /etc/mysql/my.cnf does not contain skip-networking. If it does, either remove that line or comment it out. Also verify that bind-address is set to your IP address instead of 127.0.0.1. If you change either of these items, restart MySQL.

NOTE: Your distribution may have a customized MySQL configuration file; in Mandriva, check /etc/sysconfig/mysqld for additional configuration. In systems that have /etc/mysql/conf.d put all local changes in a file, such as mythtv.cnf. For example:

[mysqld]
bind-address=0.0.0.0

By doing the above, if the mysql package manager changes my.cnf, then local changes won't be overwritten.

mariadb users should use the same concept. However, be sure to check /etc/mysql/my.cnf first to see the order of the files it includes. One example is:

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

That means that changes make in the 'old' conf.d directory could be overwritten by changes in mariadb.conf.d. Also note that the individual .cnf files are parsed alphabetically. Since /etc/mysql/mariadb.conf.d/mysql.cnf contains a setting for bind-address, overriding it must be done in a file alphabetically greater than it. /etc/mysql/mariadb.conf.d/mythtv.cnf will work fine in this case. Just be sure that there aren't any other .cnf files that would override it's changes.