htdocs and mysql data on separate partition?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

htdocs and mysql data on separate partition?

Postby Reveller » 24. April 2009 18:50

I have installed XAMPP on my C-drive. Hence, Apache htdocs is located at c:\program files\xampp\htdocs and MySQL databases in c:\program files\xampp\mysql\data.

I have created a separate partition D. I now would like to store htdocs and MySQL data on the D-drive:
  • d:\htdocs
  • d:\mysql_data
Is this possible, and if so, how do I have to configure this?

Your help would be greatly appreciated! :)
Reveller
 
Posts: 3
Joined: 24. April 2009 18:45

Re: htdocs and mysql data on separate partition?

Postby Sharley » 26. April 2009 23:30

Reveller wrote:I have installed XAMPP on my C-drive. Hence, Apache htdocs is located at c:\program files\xampp\htdocs and MySQL databases in c:\program files\xampp\mysql\data.
First of all, it is not a good idea to install XAMPP into a folder with a space in the name - Program Files being such a folder which is not recommended - install to the root of a drive or partition like C:\ then XAMPP will be installed to C:\xampp folder. Spaces in folder names may give you some headaches down the track.

Reveller wrote:I have created a separate partition D. I now would like to store htdocs and MySQL data on the D-drive:
  • d:\htdocs
  • d:\mysql_data
Is this possible, and if so, how do I have to configure this?

Your help would be greatly appreciated! :)
You can tell Apache where the DocumentRoot folder is in the xampp\apache\conf\httpd.conf file:
DocumentRoot "D:/htdocs"
<Directory "D:/htdocs">
Save the file and restart Apache.

Also check in the xampp\apache\conf\extra folder in any of the other conf files that may point to the C:\Program Files\xampp\htdocs folder and change them to the new location, save and restart as above.


The MySQL data is stored in xampp\mysql\data folder which can be copied and pasted in the new location D:\mysql_data

You now have to tell MySQL where to look for this folder.
Open xampp\mysql\bin folder and look for the my.ini file or it may just look like a shortcut my which you drag into an open text editor.

Look for this line and edit accordingly:
datadir="C:/xampp/mysql/data" <--this path is from my default installation

Edit so it looks like this:
datadir="D:/mysql_data"

Check the rest of the file for any entries that may need to be edited to reflect the new location of the data folder.
Save the file and restart Apache and MySQL.

Hope this helps and points you in the right direction.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: htdocs and mysql data on separate partition?

Postby Reveller » 27. April 2009 11:53

Thanks for a great reply. I now have used documentroot to move the apache htdocs folder over to d:\htdocs.

However, I'm having problems with MySQL. I have moved c:\program files\xampp\mysql\data over to d: and renamed it to d:\mysql. I have changed c:\program files\xampp\mysql\bin\my.ini accordingly, but now MySQL will not start. Some testing:

Code: Select all
C:\Program Files\xampp\mysql\bin>mysqladmin -h localhost 3306
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to MySQL server on 'localhost' (10061)'
Check that mysqld is running on localhost and that the port is 3306.
You can check this by doing 'telnet localhost 3306'

C:\Program Files\xampp\mysql\bin>telnet localhost 3306
Connecting To localhost...Could not open connection to the host, on port 3306: Connect failed

C:\Program Files\xampp\mysql\bin>mysqld /?
090427 11:16:25 [Warning] Can't create test file C:\Program Files\xampp\mysql\data\msi.lower-test
090427 11:16:25 [Warning] Can't create test file C:\Program Files\xampp\mysql\data\msi.lower-test
mysqld: Can't change dir to 'C:\Program Files\xampp\mysql\data\' (Errcode: 2)
090427 11:16:25 [ERROR] Aborting
090427 11:16:25 [Note] mysqld: Shutdown complete

I don't understand why MySQL keeps looking for the data directory on c: since I have clearly moved it. Please look at my.ini underneath. Does anybody have an idea of what I'm doing wrong?

P.S. I have taken your point on not installing xampp under program files, but since I have already done so, I would like to go with it for now. A good point for next time, BTW :)
Code: Select all
[client]
port   = 3306
socket = "C:/Program Files/xampp/mysql/mysql.sock"

[mysqld]
port    = 3306
socket  = "C:/Program Files/xampp/mysql/mysql.sock"
basedir = "C:/Program Files/xampp/mysql"
tmpdir  = "C:/Program Files/xampp/tmp"
datadir = "D:/mysql"

skip-locking

key_buffer              = 16M
max_allowed_packet      = 1M
table_cache             = 64
sort_buffer_size        = 512K
net_buffer_length       = 8K
read_buffer_size        = 256K
read_rnd_buffer_size    = 512K
myisam_sort_buffer_size = 8M

log_error = "D:/mysql/mysql_error.log"

skip-federated

server-id = 1

# Comment the following if you are using InnoDB tables
#skip-innodb
innodb_data_home_dir            = "D:/mysql"
innodb_data_file_path           = ibdata1:10M:autoextend
innodb_log_group_home_dir       = "D:/mysql"
innodb_buffer_pool_size         = 16M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size            = 5M
innodb_log_buffer_size          = 8M
innodb_flush_log_at_trx_commit  = 1
innodb_lock_wait_timeout        = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
Reveller
 
Posts: 3
Joined: 24. April 2009 18:45

Re: htdocs and mysql data on separate partition?

Postby Sharley » 27. April 2009 12:03

How are you trying to start MySQL?

Your first 2 error messages indicate that MySQL is not running.

The last mysqld /? will give an error similar to this in the *.err log file:
mysqld: Too many arguments (first extra is '/?').
Use --verbose --help to get a list of available options
090427 21:07:30 [ERROR] Aborting


Try starting MySQL using the xampp\mysql_start.bat file and look for any messages that might give you some clues why it can't start.

There is also and error file in the xampp\mysql\data folder *.err that might also contain some clues.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: htdocs and mysql data on separate partition?

Postby Reveller » 27. April 2009 12:18

When running the .bat file, I got a popup from my XP firewall, asking me to unblock mysql. So the problem was the firewall...I unblocked it, and now everything seems to run perfectly.

Thanks for the help!
Reveller
 
Posts: 3
Joined: 24. April 2009 18:45


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 71 guests