Are you having trouble with errors related to the mysql connection from 'mythtv-setup'? Give this script a try and see if it helps narrow down your problem.
As I get feedback from others and think of additional tests, I'll revise this script as we go. My hope is this will help with some of the more basic and common mysql configuration issues. Clearly it's not the be-all-end-all configuration test, but it should help provide some clues!
This script requires perl, bash, and mysql client to execute. Save this to a file, make it executable, and give it a try - running as the same user you plan to run 'mythtv-setup' as (this is important, the script will NOT WORK unless run as the same user you run 'mythtv-setup' as!)
Have feedback or problems, please let me know. It's OK to pm me with suggestions or feedback related directly to the execution of this script, but please do NOT pm me for questions related with how to run the script or to fix problems identified by this, please go ahead and start a new topic to discuss instead. Thanks for your understanding, my goal is to help with some common+basic configuration issues.
If everything is working properly the script should output something along the lines of:Code:#!/usr/bin/perl # # mythdb_validate.pl # # Do some basic validation for mythtv mysql configuration. # # 2007-02-13 - scotte - Created # 2007-02-14 - scotte - Updated - now batches errors, checks groups # $MROOT=$ENV{"HOME"}."/.mythtv"; $MYCNF="$MROOT/mysql.txt"; $USER=$ENV{"USER"}; $BASH="/bin/bash"; $MYSQL="/usr/bin/mysql"; $failed=0; print "Directory being checked is '$MROOT'.\n"; print "User running this script is '$USER'.\n"; if ($USER eq "root") { print "\nAs a general rule it's a bad idea to configure and run mythtv as the root user.\n"; print "This script will continue but the results will not be accurate.\n"; print "Are you really sure you want to do everything as 'root'?\n"; } print "Checking file and directory permissions.\n"; -e $MROOT || fail2("$MROOT does not exist!"); -o $MROOT || fail2("$MROOT is not owned by you!"); -r $MROOT || fail2("$MROOT is not readable!"); -w $MROOT || fail2("$MROOT is not writable!"); -x $MROOT || fail2("$MROOT is not executable!"); -e $MYCNF || fail2("$MYCNF does not exist!"); -o $MYCNF || fail2("$MYCNF is not owned by you!"); -r $MYCNF || fail2("$MYCNF is not readable!"); -w $MYCNF || fail2("$MYCNF is not writable!"); !$failed || fail(); print "Checking '$MYCNF'\n"; open (CONF, $MYCNF) || die ("Unable to open $MYCNF"); while(<CONF>) { if (/^DBHostName=(.+)$/) { $dbhost=$1; } elsif (/^DBUserName=(.+)$/) { $dbuser=$1; } elsif (/^DBPassword=(.+)$/) { $dbpass=$1; } elsif (/^DBName=(.+)$/) { $dbname=$1; } elsif (/^DBType=(.+)$/) { $dbtype=$1; } } close(CONF); $dbhost || fail2("DBHostName was not found in $MYCNF!"); $dbuser || fail2("DBUserName was not found in $MYCNF!"); $dbpass || fail2("DBPassword was not found in $MYCNF!"); $dbname || fail2("DBName was not found in $MYCNF!"); $dbtype || fail2("DBType was not found in $MYCNF!"); !$failed || fail(); $dbtype eq "QMYSQL3" || fail("DBType is '$dbtype' but we were expecting 'QMYSQL3'.\nThis script only supports mysql."); print "Trying to connect to mysql.\n"; open(MYSQL, "$BASH -c 'echo exit|$MYSQL -vvv -u $dbuser --password=$dbpass -h $dbhost $dbname' 2>&1|") || die ("Unable to run mysql command"); $worked=0; while(<MYSQL>) { if (/^Bye$/) { $worked=1; } else { $buffer=$buffer.$_; } } close(MYSQL); if (!$worked) { print "\nmysql test failed. Here's the results:\n\n"; print "=====\n"; print $buffer; print "=====\n"; fail("mysql test reported the above error. Your mysql configuration is not correct!"); } print "Checking group permissions.\n"; @gids=split(/\s/,$(); foreach $i (@gids) { $name=getgrgid($i); if ($name eq "audio") { $audio=1; } if ($name eq "video") { $video=1; } } $audio || fail2("You are not in the 'audio' group!"); $video || fail2("You are not in the 'video' group!"); !$failed || fail(); print "\nOK, all tests detectable by this script have passed.\n"; print "Please try running 'mythtv-setup' AS THE USER '$USER'.\n\n"; print "If mythtv is still unable to connect to the database then it's a failure that\n"; print "this script isn't smart enough to know about. Please report back to the\n"; print "mythtvtalk forums.\n"; sub fail2() { $failed || print "\n"; print "STOP! $_[0]\n"; $failed=1; } sub fail() { !$_[0] || print "\nSTOP! $_[0]\n"; print "\nYour configuration is not correct!\n\n"; print "Please check that '$MROOT' exists and that it, and everything\n"; print "in it is owned by '$USER' and that you have write permission.\n"; print "Please check '$MYCNF' is correct as well.\n"; print "Have you followed the documentation to the letter?\n"; print "This script is intentionally very picky about the formatting in\n"; print "'$MYCNF'. Make sure there is no whitespace\n"; print "in non-comment lines.\n"; exit 1; }
Directory being checked is '/home/mythtv/.mythtv'.
User running this script is 'mythtv'.
Checking file and directory permissions.
Checking '/home/mythtv/.mythtv/mysql.txt'
Trying to connect to mysql.
Checking group permissions.
OK, all tests detectable by this script have passed.
Please try running 'mythtv-setup' AS THE USER 'mythtv'.
If mythtv is still unable to connect to the database then it's a failure that
this script isn't smart enough to know about. Please report back to the
mythtvtalk forums.
Edit by Coume: I made this post a sticky one, as it should help lots of users.


LinkBack URL
About LinkBacks










