I am working on an application which requires me to download a database (basically database files - .myd, .frm, .myi and db.opt) from a server and load them to the local MySQL database.
Now I am able to get the files successfully and replace the existing files with the new ones in local database folder. But the problem is that MySQL continues to read the files from the previous database.
I tried stopping and restarting the server manually, with root privileges, and then the MySQL was reading proper files. But the problem is that I can not do this from the code because the code may be executed from an account that doesn't have root privileges.
So can someone please help me with a way with which I can refresh the database or make the database read proper new files.
Also, I was just wondering if I have replaced the older files from the database, how come the database can still read those files ?
Welcome to the Ranch
I shall move this discussion to one of our database fora.
You cannot simply replace files in a database. Your files contain SQL instructions (I hope) which allow you to update the database. You would have to execute them, possibly from the MySQL command line.
well actually you can, in my old company we just used to share the mysql files to test problems, or if somebody updated the schema, a cry would go round the office (we didn't have email) "updated the schema new file on shared drive"
But this only works on the older MySql database types, not with the new setting that was introduced in MySQL 5.
But as to the problem it is insumountable, you really can't go round giving every user root privilages, and you can't go round letting every user reboot your database.
Why do you want everyone being able to change your DB on the fly?
Joined: Aug 09, 2012
Actually the application is a client which will download the db files from a remote server and copy those files in the local mysql database. The previous files in the db are deleted and new ones are placed in that location.
Now, every user can not be a root user but they are allowed to run this application. So I was wondering if there is a way where in the mysql database can reload the database after the file copying operation is over.
As far as my understanding goes , non - root users can not stop and start mysql service.
So the only option left with me is to drop the database and reload it again. But that is also not happening, it throws MySQL Error 13 - Error on delete <DBname>/db.opt