Is it possible to make changes in mysql's my.ini file using PHP script?

Is it possible to make changes in mysql's my.ini file using PHP script?

Answers


Sure - it's just a text file.

However, you would have to locate the correct INI file, stop the mySQL service, make the change, and start the service again. That's going to be tough. Your PHP script would probably need root privileges to stop and restart the service, and a PHP script should never have root privileges.

Update: A combination of these should work:

PHP commands to change the file: (enter www.php.net/commandname to be redirected to the manual)

  • fopen()
  • fwrite
  • fclose

PHP command to execute an external command:

  • exec()

Windows commands to stop and restart a service: net stop / net start

As to how to locate the my.ini programmatically, I have no idea. If you can, set that manually.


Assuming the user PHP runs as has permissions to edit that file, then yes.

The question is more why do you need to edit the my.ini file with a php script?


Since it is a regular file, you can open it with PHP file handling functions and make any change you want, if you have the right permissions on the file.


Need Your Help

How to work around LocalFileSettingsProvider requiring Full Control/OwnerRights

c# .net fileshare settings roaming-profile

In my .NET client application I use the default settings provider with Scope=User and Roaming=True. This works fine in most environments, no matter if client or Terminal Server, except for a customer