![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Server Platforms Discussion regarding the Ubuntu Server Edition. For more information on the Ubuntu Server Team, please visit their wiki page or Launchpad page. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
First Cup of Ubuntu
![]() Join Date: Dec 2007
Beans: 2
|
MySQL won't start after changing datadir
I'm attempting to change the datadir of a fresh MySQL install. After changing the datadir, MySQL will no longer start. It doesn't give any reasons, it simply says [fail]. When I change the datadir back to the default (/var/lib/mysql), MySQL starts fine. Ultimately, I would like the datadir to be a folder on a different partition and disk, but for testing purposes I have tried using a folder on the same partition and disk (/home/jeremy/test) but cannot get it to work.
Things I have tried:
I've also made sure that mysql is stopped before making any changes to any files whatsoever. Once again, this is a fresh install with nothing created. It starts/works fine when the datadir is set to the default but not when I change it to anything else. Any help is greatly appreciated! |
|
|
|
|
|
#2 |
|
First Cup of Ubuntu
![]() Join Date: Dec 2007
Beans: 2
|
Re: MySQL won't start after changing datadir
After spending way, way, way, way, way, way, way (each way equals ~ an hour of my time) on this, the solution was disgustingly simple.
Basically, you need to add the directories you want MySQL to be able to access to MySQL's apparmor profile. These steps, in order, should allow you to change MySQL's datadir even if you have existing databases. Run the following commands (as root when necessary): /etc/init.d/mysql stop cp -rp /var/lib/mysql /new/mysql/dir vi /etc/apparmor.d/usr.sbin.mysqld Add the following two lines to the bottom: /new/mysql/dir r, /new/mysql/dir/** rwk, /etc/init.d/apparmor restart vi /etc/mysql/my.cnf Change datadir from: datadir=/var/lib/mysql to: datadir=/new/mysql/dir /etc/init.d/mysql restart Why does this seem so easy retrospectively? |
|
|
|
|
|
#3 |
|
First Cup of Ubuntu
![]() Join Date: Sep 2008
Beans: 2
|
Re: MySQL won't start after changing datadir
hi christonabike. I follow your thread step by step.
But still can't start mysql after changing datadir. My ubuntu version is Linux version 2.6.24-16-server (buildd@palmer) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Thu Apr 10 13:58:00 UTC 2008. |
|
|
|
|
|
#4 |
|
First Cup of Ubuntu
![]() Join Date: Sep 2008
Beans: 2
|
Re: MySQL won't start after changing datadir
this is my error log in /var/log/syslog
Sep 9 00:41:54 www kernel: [46577.909134] audit(1220892114.838:76): type=1503 operation="inode_create" requested_mask="w::" denied_mask="w::" name="/ape/mysqldata/www.lower-test" pid=10522 profile="/usr/sbin /mysqld" namespace="default" Sep 9 00:41:54 www mysqld[10524]: 080909 0:41:54 [Warning] Can't create test file /ape/mysqldata/www.l ower-test Sep 9 00:41:54 www mysqld[10524]: 080909 0:41:54 [Warning] Can't create test file /ape/mysqldata/www.l ower-test Sep 9 00:41:54 www kernel: [46577.931154] audit(1220892114.858:77): type=1503 operation="inode_permissi on" requested_mask="rw::" denied_mask="rw::" name="/ape/mysqldata/ibdata1" pid=10522 profile="/usr/sbin/ mysqld" namespace="default" Sep 9 00:41:54 www mysqld[10524]: 080909 0:41:54 InnoDB: Operating system error number 13 in a file o peration. Sep 9 00:41:54 www mysqld[10524]: InnoDB: The error means mysqld does not have the access rights to Sep 9 00:41:54 www mysqld[10524]: InnoDB: the directory. Sep 9 00:41:54 www mysqld[10524]: InnoDB: File name ./ibdata1 Sep 9 00:41:54 www mysqld[10524]: InnoDB: File operation call: 'open'. Sep 9 00:41:54 www mysqld[10524]: InnoDB: Cannot continue operation. Sep 9 00:41:54 www mysqld_safe[10530]: ended Sep 9 00:42:08 www /etc/init.d/mysql[10680]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file =/etc/mysql/debian.cnf ping' resulted in Sep 9 00:42:08 www /etc/init.d/mysql[10680]: ^G/usr/bin/mysqladmin: connect to server at 'localhost' fa iled Sep 9 00:42:08 www /etc/init.d/mysql[10680]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Sep 9 00:42:08 www /etc/init.d/mysql[10680]: Check that mysqld is running and that the socket: '/var/ru n/mysqld/mysqld.sock' exists! Sep 9 00:42:08 www /etc/init.d/mysql[10680]: |
|
|
|
|
|
#5 |
|
First Cup of Ubuntu
![]() Join Date: Mar 2007
Beans: 4
Ubuntu 7.04 Feisty Fawn
|
Re: MySQL won't start after changing datadir
Thank you for your information.
I run into this problem and solved with this thread. I was running mysql installed through the synaptic - edit - mark packages by task - LAMP Server in Hardy. |
|
|
|
|
|
#6 |
|
First Cup of Ubuntu
![]() Join Date: Jun 2009
Beans: 2
|
Re: MySQL won't start after changing datadir
Moving Mysql Databases to a different drive.
Open the Terminal Root -i This makes you the root user.Now we need to edit some files so that MYSQL can find the database. We will be using the VI editor so if you don't know how to use it, please do a google search before you begin. vi /etc/apparmor.d/usr.sbin.mysqldIf you have made it to the end with no errors your databases will now be accesable in there new location. |
|
|
|
| Bookmarks |
| Tags |
| datadir, mysql, mysqld |
| Thread Tools | |
| Display Modes | |
|
|