MySQL/Setting up MySQL: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Ivanmmj
Line 125: Line 125:


{{Next|[[HOW-TO:Share libraries using MySQL/Setting up XBMC|Setting up XBMC]]}}
{{Next|[[HOW-TO:Share libraries using MySQL/Setting up XBMC|Setting up XBMC]]}}
== See also ==
*[[MythTV:Category:MySQL]]

Revision as of 04:04, 21 July 2013

HOW-TO:Sync multiple libraries/Contents

You'll need to choose which of your computers, XBMC 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 XBMC device that is hosting most or all of your videos and music to also be the MySQL server, but this is not required.

Emblem-important-yellow.png NOTICE:
Users are reporting issues with MySQL 5.6. Use MySQL 5.5 instead.

MySQL can be installed on just about every major OS:

[edit]

Ubuntu Linux:

  1. $sudo apt-get install mysql-server (see also: https://help.ubuntu.com/10.04/serverguide/C/mysql.html )
  2. Create a password when asked
  3. To configure MySQL to listen for connections from network hosts, edit /etc/mysql/my.cnf and change the bind-address directive to the server's IP address:
    1. from: bind-address = 127.0.0.1
    2. to: bind-address = 192.168.0.5
    • Note: Replace 192.168.0.5 with the appropriate address.
    • Note: To allow local and remote access try comment out bind-address using a hash(#) or use bind-address = 0.0.0.0
  4. Restart your MySQL server. $sudo restart mysql
  5. Get into the MySQL command line utility: $mysql -u root -p
  6. Enter the following commands:
    1. Type in: CREATE USER 'xbmc' IDENTIFIED BY 'xbmc'; and press return
    2. Type in: GRANT ALL ON *.* TO 'xbmc'; and press return
  7. Close out the command line tool with \q
[edit]

Arch Linux:

  • Please note: Arch, along with many other distributions, has migrated to the faster and more open MariaDB. It is a drop in replacement to MySQL and, thus, XBMC will require no modifications to work with it.
  1. Install MariaDB: $sudo pacman -S mariadb
  2. Start the service: $sudo systemctl start mysqld
  3. To have it automatically launch at startup: sudo systemctl start mysqld.service
  4. Create a password: $/usr/bin/mysql_secure_installation This will also clean up the demo database.
  5. Get into the MariaDB command line utility: $mysql -u root -p
  6. Enter the following commands:
    1. Type in: CREATE USER 'xbmc' IDENTIFIED BY 'xbmc'; and press return
    2. Type in: GRANT ALL ON *.* TO 'xbmc'; and press return
  7. Close out the command line tool with \q
[edit]

RedHat based Linux (RHEL, CentOS, Fedora):

  1. $sudo yum install mysql-server
  2. Create a password when asked
  3. To configure MySQL to listen for connections only from network hosts, edit /etc/mysql/my.cnf and add the bind-address directive to the server's IP address:
    bind-address = 192.168.0.5
    • Note: Replace 192.168.0.5 with the appropriate address.
    • Note: Alternatively you can leave this file as is to allow local and remote access.
  4. Restart your MySQL server. $sudo /sbin/service mysqld restart
    • Recommended - Set your MySQL root password with /usr/bin/mysqladmin -u root password 'new-password'
  5. Get into the MySQL command line utility: $mysql -u root -p
    • Enter your MySQL root password as set above, or just press enter if you didn't set one to log in with a blank password
  6. Enter the following commands:
    1. Type in: CREATE USER 'xbmc' IDENTIFIED BY 'xbmc'; and press return
    2. Type in: GRANT ALL ON *.* TO 'xbmc'; and press return
  7. Close out the command line tool with \q
[edit]

Mac OS X:

  1. Download a copy of MySQL server from http://dev.mysql.com/downloads/mysql/
  2. In Mac OS X, go to System Preferences -> MySQL, and click on “Start MySQL Server”. You’ll also want to tick to enable the “Automatically … on Startup” option.
  3. Now to set up the "xbmc" user in MySQL and give it access. Launch Terminal.app on your Mac and issue the following commands, one line at a time:
    1. sudo /usr/local/mysql/bin/mysql
    2. CREATE USER 'xbmc' IDENTIFIED BY 'xbmc';
    3. GRANT ALL ON *.* TO 'xbmc';
    4. exit
  4. Remain in Terminal.app. Now you'll be giving other computers on your network access to MySQL. Enter the next set of commands, one line at a time:
    1. cd /usr/local/mysql/support-files/
    2. sudo cp my-huge.cnf /etc/my.cnf
      The command line will ask for your Mac OS X user password. Enter it and press return. No text will show when you type your password in, this is normal.
    3. cd /etc
    4. sudo nano my.cnf
      This opens a file in a command line text editor
    5. Scroll down to the [mysqld] section and add or edit the following line so that it appears as:
      bind-address = ***.***.***.***
    6. Save and exit from the command line text editor
  5. Reboot the Mac, or restart the MySQL service from the System Preferences pane you installed earlier


[edit]

Windows:

  1. Download a copy of MySQL server from http://dev.mysql.com/downloads/mysql/
  2. Select Standard configuration
  3. Create a password when asked
  4. Select that you want the database to have network access when prompted during installation.
  5. Open the "MySQL Command Line Client" from the MySQL start menu
  6. Enter the following commands:
    1. Type in: CREATE USER 'xbmc' IDENTIFIED BY 'xbmc'; and press return
    2. Type in: GRANT ALL ON *.* TO 'xbmc'; and press return
  7. Close out the command line tool
  8. In Windows 7, you may need to make an exception in the "Windows Firewall"
    1. Go to control panel and open windows firewall
    2. Click on advanced settings
    3. Click on Inbound Rules, then new rule
    4. Chose the port option, click next
    5. Then type in the port number you set mysql to use(Default is 3306)
    6. Make sure Allow the connection is checked then click next
    7. Name it MYSQL Inbound(or whatever you want) then click finish
    8. Use these same steps to set up the Outbound exception then name it MYSQL Outbound(or whatever you want) then you're finished.
    You may or may not have to set up both in and outbound, someone with more knowledge please edit this if you know.
  9. In Windows XP, you may need to make an exception in the "Windows Firewall"
    1. Open Control Panel and Set to 'Classic View'
    2. Double Click on Windows Firewall
    3. Click on Exception-->Add Port
    4. Name It MySQL XBMC or whatever you want
    5. Then type in the port number you set mysql to use(Default is 3306)
    Note: You must do this twice:Once for UDP and once for TCP

Note: If XBMC is unable to connect to the MySQL server, returning an error code [1130]:
If this occurs to you, try amending Step 2 above to read GRANT ALL ON *.* TO 'xbmc'@'xxx.xxx.xxx.%'; where xxx.xxx.xxx is the first three quadrants of your home network's IP address (192.168.1 for example) and % as the last quadrant to allow addresses on the same subnet to connect.

[edit]

MySQL can also be installed on some network-attached storage (NAS) device devices. Here are some guides for various NAS devices that can have a MySQL server installed:


Next step: Setting up XBMC