mysql and changed place of DB and mysql.sock

Discuss Applications
Post Reply
User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

mysql and changed place of DB and mysql.sock

Post by Basher52 » Fri Feb 12, 2010 5:05 pm

Can't remember if I posted anything like this before and I can't find anything of it in here so I ask (again).

On the new server I want the databases and the websites on a partition on its own so I installed mysql and changed the /etc/my.cnf.
Changed the datadir and socket from '/var/lib/mysql' so the place I want the DB to be placed. I did this on the older server with no problems but with symlinks, but with this server I first couldn't start phpMyAdmin that just said: #2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

So I started to google about it and found to test mysqladmin too and that one said:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
so I knew that something was corrupt. I started to look around google and they said like, look in /tmp or your home dir and stuff, but I can't find ANY my.cnf on any place other than /etc/my.cnf.

I thought that I disabled the SELinux at install, but later I found out that I didn't but now I've set the /etc/selinux/config and the parameter to: SELINUX=disabled. I still see some "dots" in the access of files and dirs, so I still wonder if it's running

Have you any idea what I've missed here?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Fri Feb 12, 2010 6:13 pm

What distro? We change the location of that on our MySQL servers at work and run multiple MySQL servers on one physical server. My guess is the /etc/init.d/mysqld script is picking up your /var/lib/mysql directory. Specifically the lines in the area that start with "get_mysql_option". It's looking for the compiled in defaults. You should be able to hard code the "datadir" and "socketfile" variables to the values you want.

For example instead of:

Code: Select all

get_mysql_option mysqld datadir "/var/lib/mysql"
datadir="$result"
get_mysql_option mysqld socket "$datadir/mysql.sock"
socketfile="$result"
you woudl have something like this:

Code: Select all

get_mysql_option mysqld datadir "/var/lib/mysql"
datadir="/yournewdatadir"
get_mysql_option mysqld socket "$datadir/mysql.sock"
socketfile="$datadir/mysql.sock"

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Fri Feb 12, 2010 9:19 pm

distro = F11
I tried the things you suggested but I still get the same result :(
I think I set some mysqldi and not mysqld somewhere but can't remember where
could that be he issue?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Fri Feb 12, 2010 9:44 pm

I'll look at our configuration at work on Monday.

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Tue Feb 16, 2010 11:15 am

Did you find anything that might cause this?

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Tue Feb 16, 2010 3:00 pm

Looks like everything you should have to change is in the /etc/init.d/mysqld script. We create additional scripts using that script as an example and change all the things that are different. For example, we would copy /etc/init.d/mysqld to /etc/init.d/mysqld_mydb and set change the things that are different:

Code: Select all

$ cd /etc/init.d
$ diff mysqld mysqld_mydb 
8,10c8,10
< # processname: mysqld
< # config: /etc/my.cnf
< # pidfile: /var/run/mysqld/mysqld.pid
---
> # processname: mysqld_mydb
> # config: /etc/my_mydb.cnf
> # pidfile: /var/run/mysqld/mysqld_mydb.pid
34c34
< get_mysql_option mysqld datadir "/var/lib/mysql"
---
> get_mysql_option mysqld datadir "/db_mydb"
38c38
< get_mysql_option mysqld_safe log-error "/var/log/mysqld.log"
---
> get_mysql_option mysqld_safe log-error "/var/log/mysqld_mydb.log"
40c40
< get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid"
---
> get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld_mydb.pid"
61c61
< 	/usr/bin/mysqld_safe   --datadir="$datadir" --socket="$socketfile" \
---
> 	/usr/bin/mysqld_safe  --defaults-extra-file=/etc/my_mydb.cnf --datadir="$datadir" --socket="$socketfile" \
86c86
< 	[ $ret -eq 0 ] && touch /var/lock/subsys/mysqld
---
> 	[ $ret -eq 0 ] && touch /var/lock/subsys/mysqld_mydb
107c107
<                     rm -f /var/lock/subsys/mysqld
---
>                     rm -f /var/lock/subsys/mysqld_mydb
127c127
<     [ -e /var/lock/subsys/mysqld ] && restart || :
---
>     [ -e /var/lock/subsys/mysqld_mydb] && restart || :


User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Thu Feb 18, 2010 11:58 am

I thought and just now tested that the function:
get_mysql_option mysqld datadir "/webdata/database/mysql"
will get the correct dir that is set in /etc/my.cnf if it can't find it it'll set the dir to the default that is the one within the quotes.

I tested to change my.cnf's datadir to /a/b/c/d... and without restarting mysqld the result was the correct dir set, so it can't be this either.

The only thing I changed in my.cnf is datadir and socket and both goes to the same dir(plus the filename in socket)

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Fri Feb 19, 2010 2:10 pm

I can't find any solution to this so I'll just keep the original settings and use a symbolic link to the new place I wanna place it.

Lots of things I get through googling keeps saying the there is a .my.cnf in the user directory but that ain't it so...
It kinda feels bad doing this since you should be able to change the settings and my.cnf is the "main" config that everyone else should "listen" in on :P

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Fri Feb 19, 2010 7:41 pm

Yeah, I'm not sure why the changes we make don't work for you when they do for us.

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Sat Feb 20, 2010 11:08 am

This is why I'm a pessimist lol

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Mon Apr 26, 2010 2:53 pm

I'm back to this problem and googled lots of people with the same problem.
I started to think that it's always the socket file that has the problem so I just changed the placement of the database and then it worked.
I'm starting to wonder if the socket file can't be placed on another disk/partition then '/'

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main » Mon Apr 26, 2010 3:03 pm

We put our socket files on different file systems without any problem. I'm still not sure why you couldn't get it to work since we are doing it.

User avatar
Basher52
guru
guru
Posts: 917
Joined: Wed Oct 22, 2003 5:57 am
Location: .SE

Post by Basher52 » Tue Apr 27, 2010 9:48 am

Same here, very weird but the important thing is the database itself so it'll do.

Post Reply