[mythtv-users] cant get mysql to work

R. G. Newbury newbury at mandamus.org
Tue Oct 13 18:25:29 UTC 2009


Tim Urben wrote:
> I tried it and got this
> 
> [root at htpc ~]# /sbin/chkconfig mysqld on
> [root at htpc ~]# /sbin/service mysqld start
> Starting MySQL:                                            [  OK  ]
> [root at htpc ~]# mysql -u root mysql
> ERROR 2002 (HY000): Can't connect to local MySQL server through socket 
> '/var/lib/mysql/mysql.sock' (2)


Jarod Wilson's pages set out all the steps. Some are no longer required, 
as drivers have migrated into the kernel, and some are no longer as 
difficult for the same reason, but the main structure is the same.

You  have mysql installed. You apparently do not yet have a mythtv user, 
and are not calling mysql correctly.

As ROOT, try:   mysql -u root

You should get a 'mysql >' prompt.

Mysql installs, by default without a password for the root account. This 
is NOT the same as your computer user 'root' account, but more like an 
'admin' for mysql.

If you get the same error, there are a couple of possible reasons.

1) Your /etc/my.cnf file points to the wrong place.
   The /etc/my.cnf file needs the following:

# file: /etc/my.cnf
[mysqld]
… # someother settings
socket=/var/lib/mysql/mysql.sock
[client]
… # some other settings
socket=/var/lib/mysql/mysql.sock

Use  'service mysqld stop', then edit the my.cnf file.

2) /etc/my.cnf points to the correct place but mysql cannot read or 
write there.
do 'service mysqld stop'
'cd' to /var/lib and do 'chown -R mysql:mysql /var/lib/mysql'
'service mysqld start'
'mysql -u root'
and see what happens.

************
At this point it appears that you do not have a 'mythtv' user under 
mysql. 'mythtv' is the user which 'talks' to the mysql database. Once 
you have a working mysql that the root user can use, you create the 
mythtv user as follows:

mysql -u root < mc.sql

where mc.sql is the following text file:

CREATE DATABASE IF NOT EXISTS mythconverg;
GRANT ALL ON mythconverg.* TO mythtv at localhost IDENTIFIED BY "mythtv";
FLUSH PRIVILEGES;
GRANT CREATE TEMPORARY TABLES ON mythconverg.* TO mythtv at localhost 
IDENTIFIED BY "mythtv";
FLUSH PRIVILEGES;
ALTER DATABASE mythconverg DEFAULT CHARACTER SET utf8 COLLATE 
utf8_general_ci;

Note that the 'mythtv' user and the 'mythtv' password (the 'identified 
by' portion) are placeholders for whatever name/password you wish to 
use, which can be your 'usual' user.

Once you have got this far, ADD A PASSWORD FOR THE ROOT USER UNDER 
MYSQL!!! If your mythbox does nothing else and you have no email, or 
bank account information, then that does not matter much. But it does 
matter if your mythbox gets compromised and any of your other computers 
ever connect to your LAN....And there are a known group of exploits 
based on compromising a mysql install.

Geoff


-- 
         Please let me know if anything I say offends you.
          I may wish to offend you again in the future.

          Tux says: "Be regular. Eat cron flakes."



More information about the mythtv-users mailing list