MySQL installed on the FreeBSD host when the database files are placed under/var/db/mysql, the default storage location on the Linux host is/var/lib/mysql/.
If you want to replace the storage location of the MySQL data file:
FreeBSD under:
#/usr/local/etc/rc.d/mysql-server Stop (stopping MySQL)
# mkdir/other/db (Create a new data file directory, you can also move directly over)
# mv/var/db/mysql/other/db (move data file)
# ln-s/other/db/mysql/var/db/mysql (set up soft links for data files)
#/usr/local/etc/rc.d/mysql-server start (starting MySQL)
Linux under:
(under the test of Linux, you can not stop the MySQL and direct operation, but if the database is often updated or first stop the good, stop the method here is not introduced!) )
# mkdir/data/database (Create a new data file directory, you can also move directly over)
# mv/var/lib/mysql/data/database/(move data file)
# ln-s/data/database/mysql/var/lib/mysql (set up soft links for data files)
If your operation user is not MySQL, such as the root user operation, it may be that MySQL has no read access to the newly established Data folder, Chown, or Chgrp,chmod!
How to modify in Windows system
1. Query data File storage location
Mysql> Show variables like ' DataDir '
->;
+---------------+-------------------+
| variable_name | Value |
+---------------+-------------------+
| DataDir | d:/mysql5.0/data/|
+---------------+-------------------+
1 row in Set (0.00 sec)
Mysql> Show variables like ' DataDir '
->;
+---------------+-------------------+
| variable_name | Value |
+---------------+-------------------+
| DataDir | d:/mysql5.0/data/|
+---------------+-------------------+
1 row in Set (0.00 sec)
2. Stop MySQL database use NET command to stop service
C:/Documents and Settings/administrator>net stop MySQL
The MySQL service is stopping.
The MySQL service has stopped successfully.
C:/Documents and Settings/administrator>net stop MySQL
The MySQL service is stopping.
The MySQL service has stopped successfully.
Of course, you can also view the MySQL directory of My.ini files
3. Modify the My.ini folder
#Path to the database root
Datadir= "D:/mysql5.0/data"
4. Start service OK
C:/Documents and settings/administrator>net start MySQL
The MySQL service is starting.
The MySQL service has started successfully.