473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Freeing .MYD and .MYI Files

After running my PHP/MySQL application, I have found that the
associated .MYD and .MYI files remain locked. Even after the browser
is closed, if I try to rename these files, I get the message:

Can't rename filename. It is being used by another person or
program...

These files remain locked until I reboot. I'm running on a Windows XP
machine.

Here is a code snippet that locks the two files:

<?php

//Connect to server and database

$host="localhost";
$user="root";
$password="";

$edenconnect = mysql_connect($host,$user,$password)
or die("Could not connect to server.");
mysql_select_db("eden")
or die("Could not connect to database.");

$sql = "SELECT * FROM edenmaster";

$result = mysql_query($sql);

$row = mysql_fetch_array($result);

mysql_free_result($result);

mysql_close(); // Also tried mysql_close($edenconnect);

exit;
?>

After running this snippet and closing the browser, files
edenmaster.myd and edenmaster.myi are locked to renaming until a
reboot.

I thought the mysql_close() would free the files, but it does not.

Any ideas?

Thanks!

Sep 7 '05 #1
4 1768
On 7 Sep 2005 12:30:09 -0700, hi***********@yahoo.com wrote:
After running my PHP/MySQL application, I have found that the
associated .MYD and .MYI files remain locked. Even after the browser
is closed, if I try to rename these files, I get the message:

Can't rename filename. It is being used by another person or
program...

These files remain locked until I reboot. I'm running on a Windows XP
machine.

After running this snippet and closing the browser, files
edenmaster.myd and edenmaster.myi are locked to renaming until a
reboot.

I thought the mysql_close() would free the files, but it does not.


Why are you expecting the files to be unlocked?

The MySQL server daemon will have them open, and there's no reason for it to
close the files whilst it's running.

Why are you renaming the files via the filesystem? To rename a table you use
the RENAME SQL command.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 7 '05 #2

Andy Hassall wrote:
Why are you expecting the files to be unlocked?

I assumed when the application closed the database, the files would be
released.
The MySQL server daemon will have them open, and there's no reason for it to
close the files whilst it's running.

Even after closing MySQL and the Apache server, the files are still
locked.
Why are you renaming the files via the filesystem? To rename a table you use
the RENAME SQL command.
I bumped into this by accident. I'm not concerned about renaming them,
just the fact that the connection still seems to be open.

Thanks!
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool


Sep 7 '05 #3
On 7 Sep 2005 12:56:51 -0700, hi***********@yahoo.com wrote:

Andy Hassall wrote:
Why are you expecting the files to be unlocked?


I assumed when the application closed the database, the files would be
released.


The application only sees the view of the database that the MySQL daemon
offers it, through SQL. The files are an implementation detail handled by the
daemon itself; the client application can't open or close them.
The MySQL server daemon will have them open, and there's no reason for it to
close the files whilst it's running.


Even after closing MySQL and the Apache server, the files are still
locked.


After closing MySQL? As in stopping the MySQL daemon? That would be more
unusual - only MySQL itself has any business accessing those files, so if you
stop the MySQL service completely then nothing else should have them open.

Could you expand on what you mean by "closing MySQL"?

You can find what has files open with a tool like Process Explorer
(http://www.sysinternals.com/Utilitie...sExplorer.html)
Why are you renaming the files via the filesystem? To rename a table you use
the RENAME SQL command.

I bumped into this by accident. I'm not concerned about renaming them,
just the fact that the connection still seems to be open.


PHP will have closed its connection, as you were using mysql_connect rather
than mysql_pconnect (which does persistent connections).

That doesn't have any implication that the MySQL daemon will close files in
response - there's no particular reason it should, it'd only have to open them
again later.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 7 '05 #4

Andy Hassall wrote:
On 7 Sep 2005 12:56:51 -0700, hi***********@yahoo.com wrote:

Could you expand on what you mean by "closing MySQL"?


I am running the Apache Friends implementation of PHP and MySQL. They
provide .bat files to start the two services which then stay resident.
I have been closing/stopping them by closing their Windows program
boxes. It looks like that does close Apache, but MySQL still appears
as a running process.

Just tried closing the MySQL process, and now the files are freed up.

Thanks for getting me on the right track!

Sep 7 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: disco | last post by:
I am working on this example from a book "C Primer Plus" by Prata 4th edition - p. 672. There is no erata on this problem at the publisher's website. 1) Is it a violation of copyright laws to...
11
by: Rodrigo Dominguez | last post by:
there are sometimes that I use third party libraries, I use some functions that returns char * or structs, etc. sometimes the memory that is returned by those libraries, when I try to free this...
6
by: Fernando Cacciola | last post by:
Help me out here please: While watching Brad Abraham's MSDN TV talk about the Dispose pattern, refering to: public virtual void Dispose ( bool disposing ) { if ( disposing ) { <-- WHAT...
4
by: Atul Sureka | last post by:
Hi, I want to free the object memory in C# - like we do using 'delete' keyword in C++. Lets say I have an object of some class and I want to explicitly free the memory. C# do not have any free...
5
by: Amogh | last post by:
Hi, My question is related to setting freed pointers to NULL. After freeing a pointer: 1) Should the freeing routine also be responsible for setting the pointer to null? 2) Or, should the...
3
by: billq | last post by:
Hello, I am new to c# and have become confused about freeing resources. I need to know if using an objects Dispose method does the same thing as setting the object to null? Pen bluePen = new...
66
by: karthikbalaguru | last post by:
Hi, Will 'free' return the memory Immediately to the OS ? Thx in advans, Karthik Balaguru
9
by: david | last post by:
I will past only two segments from the code it should be enough to see what I did wrong, I think I know there I made a mistake, but how to fix it I can not tell. This why I need help from you all....
11
by: vivek | last post by:
Hello, I have a pointer to a main structure which again consists of structures, enums, char, int, float and again complex structures. When i free all the contents of the main structure, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.