FreeBSD Jail mysql connecting problems

I'm using mysql in a jail and I am having problems importing my sql backups.

When I run:
Code:
mysql  -u root -p -h localhost cncrepair < cncrepair_2012_03_08_1.sql
I get the following error:
Code:
Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

However, I can log into to the mysql deamon just fine with:
Code:
 mysql  -u root -p

The root user has full privileges over the 'cncrepair' database. The mysql website (http://dev.mysql.com/doc/refman/5.1/en/access-denied.html) suggests that maybe there is an incorrect option file. However, I have not set up any of the template/default .cnf files.

I ended up compressing the sql file and using phpmyadmin to do the initial import but I would still like to know what's causing the error.
 
There is no localhost inside a jail. You need to connect to the jail's IP address. You also need to make sure MySQL is bound to only the jail's IP address.
 
What exactly should the jails /etc/hosts file look like? This is what i have:
Code:
 ::1,,...,...localhost localhost.my.domain
 14 127.0.0.1,..,...localhost localhost.my.domain
 15 192.168.1.160,..,...localhost localhost.my.domain apache

I also created a /usr/local/etc/mysql/my.cnf file and added the option:
Code:
bind-address=191.168.1.160

I still get host related errors though.
 
I accidentally copied the line numbers 14, 15 from /etc/hosts and forgot to edit them out. So the file really looks like:
Code:
::1,,...,...localhost localhost.my.domain
 127.0.0.1,..,...localhost localhost.my.domain
 192.168.1.160,..,...localhost localhost.my.domain apache
 
Once I stopped messing around with host name related changes I figured out the problem. I believe there is a jail conflict with stdout, stderr, and ttys. The mysql tools work fine with redirection (<) when I omit -p (password) option. You can circumvent this problem by either ssh'ing into the jail or using tmux.

More information can be found here:
Code:
http://lists.freebsd.org/pipermail/freebsd-jail/2011-August/001599.html
and here:
Code:
http://forums.freebsd.org/showthread.php?t=22889

Now I want four hours of my time back.
 
Don't assign any other IP address than 127.0.0.1 or ::1 to localhost. Those commas and periods should be there either.

Code:
::1                     localhost localhost.my.domain
127.0.0.1               localhost localhost.my.domain
If you need your hostname to resolve add it like so:
Code:
192.168.1.160            myhost.mydomain
Replace myhost.mydomain for the FQDN of your jail's hostname.
 
My /etc/hosts in the jail apache looks like this now:
Code:
::1             localhost localhost.my.domain
127.0.0.1       localhost localhost.my.domain
192.168.1.160   apache apache.my.domain apache

I have also bound mysql to the ip 192.168.1.160

The periods, commas and line numbers were all artifacts from vim that I forgot to remove when pasting into the reply box. I couldn't edit the posts (seems I need a minimum of ten posts for that). Every thing seems to be working now. Thanks for your help, it was appreciated.
 
Back
Top