Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

mysql

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

like image 401
OM The Eternity Avatar asked Apr 07 '10 10:04

OM The Eternity


People also ask

How do I open an ini file in MySQL?

ini file for MySQL Server on Windows Machine. In you have default installation on Windows machine for MySQL Server, you will be able to find the my. ini file in C:\ProgramData\MySQL\MySQL Server XX\. The XX defined the version of MySQL server.

Where can I find my ini file in Windows?

First go to C: drive and then hidden folder of program data. From that, move to the MySQL version directory. Here is the my. ini file.


1 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

  • http://technet.microsoft.com/en-us/library/bb490715.aspx

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

like image 63
Pekka Avatar answered Sep 18 '22 10:09

Pekka