Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change database files location in MySQL administrator?

Tags:

mysql

I would like to change the database files location of MySQL administrator to another drive of my computer. (I run Windows XP SP2 and MySQL Administrator 1.2.8.)

--Under the startup variable --> General Parameters --> I changed Data directory: from C:/Program Files/MySQL/MySQL Server 5.0/data to D:/....., but after I stopped the service and restarted it, the following error appeared:

Could not re-connect to the MySQL Server.
Server could not be started.

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

Has anyone else had this problem?

like image 210
vuthaKH Avatar asked Sep 24 '08 10:09

vuthaKH


People also ask

Where is MySQL database file location?

The default data directory location is C:\Program Files\MySQL\MySQL Server 8.0\data , or C:\ProgramData\Mysql on Windows 7 and Windows Server 2008. The C:\ProgramData directory is hidden by default. You need to change your folder options to see the directory and contents.


2 Answers

Normally it works like this:

  1. shut down MySQL
  2. change the [mysqld] and [mysqld_safe] datadir variable in the MySQL configuration
  3. change the basedir variable in the same section.
  4. move the location over
  5. restart MySQL

If that doesn't work I have no idea. On linux you can try to move the socket to a new location too, but that shouldn't affect windows. Alternatively you can use a symbolic link on *nix what most people do I guess.

like image 56
Armin Ronacher Avatar answered Sep 21 '22 17:09

Armin Ronacher


In Windows

  1. Navigate to C:\Program Files\MySQL\MySQL Server 5.4\ and locate the my.ini file
  2. Find the SERVER SECTION and go to approx line 76 and modify the datadir line to where you want your MySQL application data to be stored
  3. Now navigate to C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.4\data\ and copy and paste the mysql folder into your new location.
  4. Restart the MySQL Server in Control Panel > Administrative Tools > Service
like image 41
ajcw Avatar answered Sep 19 '22 17:09

ajcw