If you only have one mysql user for accessing all your databases, restoring directly from a sql file does not have much more security improvement over using phpmyadmin. Using a hosting package with the ability of managing mysql users is a good solution.
Otherwise you have to verify an uploaded sql file before restoring from this file. In the following you will find three suggestions on how you could verify an uploaded file.
All of the suggestions build on the assumption that you use a sql file, which has been generated on the server. Create a digital signature at download and validate the signature at upload. For sure, you have to upload the digital signature together with the sql.
Store a hash value of the downloaded sql on the server and check for existents of this hash value at upload. Using an ID for the sql files might be helpful. Save the whole sql files on the server and only allow restores from these files. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to download and upload SQL database as. Ask Question. Asked 7 years ago. Active 7 years ago. Viewed 8k times. I need a php code which downloads and uploads one database file. Backup: I need a help to download database data as. Restore: I should also be able to upload the same. EDIT I know its possible via phpmyadmin and cannot use it as I am going to let my clients download the sql file.
Thank you. Improve this question. Can you just install phpMyAdmin and use that? Just use mysqldump,you write one line,bam,done. Why complicate yourself with php? This is all You need to do that: stackoverflow. How can I protect my eyes from flying splinters? Show 9 more comments. Active Oldest Votes. It's easier if you don't use php for this.
I don't like use the command exec but Improve this answer. Serpes Serpes 4 4 silver badges 13 13 bronze badges. Just use gzip to compress into a. You are right. I'm used to use tar for this kind of stuffs. Sometimes it's one file and sometimes it's more than one. But, yes, gzip would be a better solution — Serpes. Add a comment. Community Bot 1 1 1 silver badge.
Luzan Baral Luzan Baral 3, 4 4 gold badges 33 33 silver badges 65 65 bronze badges. I have seen this code before. It doesn't handle NULL.
It doesn't delimit table names or column names properly. It doesn't handle character sets. And worst of all, this code appends the all its output into a single string , which will exceed PHP's memory limit unless you database is trivially small.
It's a very bad solution. In a query editor type and execute the following code:. After executing the above code, the following message will appear that indicate that the show advanced options and Ad Hoc Distributed Queries options are enabled:. It is already opened exclusively by another user, or you need permission to view and write its data. This usually happens because of inadequate permissions.
More about how to resolving these issues can be found in the How to query Excel data using SQL Server linked servers page. One way for resolving this issue is to open SSMS as an administrator and execute the code again. But this time, another error may appear:. Msg , Level 16, State 1, Line 1 Column name or number of supplied values does not match table definition.
To resolved this, open excel file e. SQL Data. DimScenario and enter the column names which will represent the column names from the DimScenario table:. In order to achieve that, open an Excel file e. This will open the Data Connection Wizard dialog. In the Log on credentials section, choose the authentication mode for the data source connection and click the Next button:. From the Select the database that contains the data you want drop down box, choose the database from which the data will be copied.
In the grid, all available tables and views will be listed. DimScenario and click the Next button to proceed. In the Import Data dialog, choose the Table radio button, under the Where do you want to put the data? From the Results grid, select data that you want to export to an Excel file, right click in the Result grid and, from the context menu, choose the Export to Excel option:.
This will open a new Excel workbook and the selected data from the Results grid will be copied in the first worksheet:. Solutions Products Downloads Prices Support. What's new. Database administration Automate critical tasks for database administration Auditing and compliance Database backup Disaster recovery Forensic auditing Index defragmentation Inventory management Load testing Object level restore Server compare SQL job automation SQL Server monitoring Transaction log reading Transactional replication.
Solution center. This will open the Choose a Destination window in which can be specified where to copy data from the data source: In the Destination drop down box, choose the Microsoft Excel item.
0コメント