7

I've got a chroot environment working on my 10.04 ubuntu box. I'm trying to run mysql inside this chroot environment, but I get this error.

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Basically I used debootstrap along with schroot to create the chroot. Then I installed "ubuntu-minimal" and mysql-server inside this chroot environment. If you are interested here are all the steps that I followed https://help.ubuntu.com/community/DebootstrapChroot . But mysql does not work inside the chroot. /var/log/mysql.log and /var/log/mysql.err files are empty and mysqld server is running. Any pointers?

Neo
  • 13,179
  • 18
  • 55
  • 80

2 Answers2

4

It is a bug with schroot. mysqld escapes chroot and interacts with systems's mysqld.

http://ubuntuforums.org/showthread.php?t=1625863 https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/430224

Neo
  • 13,179
  • 18
  • 55
  • 80
1

make sure mysql have write permission. try running mysql as root. If it works fix the file permission so mysql have write permission and restart mysql as normal user. .

Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
  • I am inside chroot as a root. So thats not a problem. – Neo Feb 20 '11 at 11:32
  • can you list the package you have installed for mysql and file permission of /var/run/mysqld/mysqld.sock – Vivek Goel Feb 20 '11 at 11:39
  • 1
    @neo, hopefully you aren't running mysqld inside the chroot as user `root`. (That would make any chroot security useless; running mysqld as root makes shivers run up my spine.) – sarnold Feb 20 '11 at 11:42
  • 1
    I simply installed `apt-get install mysql-server` in the chroot. And /var/run/mysqld directory is empty. – Neo Feb 20 '11 at 11:45
  • @sarnold - Yep, I'm doing it as root, but just for the time being. Atleast it should start working and then I can change the permissions. – Neo Feb 20 '11 at 11:46
  • than follow the instruction here http://ubuntuforums.org/showthread.php?t=276470&page=2 see the #17 post – Vivek Goel Feb 20 '11 at 11:47
  • @vivek - Interesting. If I just create that sock file and restart my mysql, the error number changes to 111. `ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)`. And If I run mysqld with root, I get access denied error. – Neo Feb 20 '11 at 11:57
  • @Neo try this and let me know http://stackoverflow.com/questions/1420839/cant-connect-to-mysql-server-error-111 – Vivek Goel Feb 20 '11 at 12:07
  • @vivek - Now, mysqld when run as root works. So I guess touching the sock file did a trick. Now onto figuring out the file permissions ;). – Neo Feb 20 '11 at 12:14
  • @Neo, it sounds like you are trying to solve a problem you don't need to solve. If you know you will eventually want to make it run as a non-root user, why are you spending time and energy trying to get it to run as root? – dj_segfault Feb 20 '11 at 15:37
  • @dj_segfault - mysqld 'does' run as root. So atleast thats working. It doesn't work when run with normal permissions i.e. non-root. – Neo Feb 20 '11 at 15:46
  • @sarnold - mysqld interacts with system's mysqld even without root permissions. Its a bug. – Neo Feb 23 '11 at 03:47