Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

Problem after moving mysql database

Hello,

When the IT dept set up my Linux server with MySQL they set the data directory to /var/lib/mysql

Now the system disk is full.

So there is a disk with loads of space which i have copied of the database to using:

cp /var/lib/mysql /data

then i edited the my.cnf file and changed the row that Points to the database to:

datadir = /data

I deleted some old log files to create some space.

Then i restarted the server.

But i now get an error message in mysqld.log that says:

Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist

How can i solve this?  I have seen examples that say you can use:

mysql_install_db –user=mysql –ldata=/newlocation

but i just want to be certain i am not doing a total new install by type in that command.

I know nothing about Linux/MySQL so keep you answers to beginner level!
0
soozh
Asked:
soozh
  • 2
2 Solutions
 
StampelCommented:
you could just move the data and symlink /var/lib/mysql to /whatever/you/want
without changing the configuration. I have done this a couple of times for production systems.
0
 
StampelCommented:
i suspect someone could have upgraded mysql without upgrading data and you are hitting this cause you did restart mysql what nobody did before.

Usually when you it this error of missing table you would run "mysql_upgrade -p"
That would fix the problem with this table
0
 
SandyCommented:
1. Stop MySQL using the following command:
sudo /etc/init.d/mysql stop

2. Copy the existing data directory (default located in /var/lib/mysql) using the following command:
sudo cp -R -p /var/lib/mysql /newpath

3. you already modified the "datadir" parameter

4. Restart MySQL with the command:

/etc/init.d/mysql restart

Hope this helps ... Keep posted

TY/SA
0
 
soozhAuthor Commented:
Thanks for the help.  I did want sandy suggested but i had copied the wrong directory level.  So now everything is working.  Thanks for the help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now