Tag Archives: tip - Page 2

Restore MySQL Dump File to a Different Database Name

Restore MySQL Data to a Different DatabaseToday I had to take a MySQL database backup from one database and then restore it to a different database name (for development/testing purposes). I tried a number of different tricks that I found online through Google without any success. The issue was that the user I was using to restore the data was NOT an administrator (root) on the database so it was failing with permission errors – always with an error related to the name of the database I restored FROM.

Okay, time to go old-school. So… I opened the .sql file that was created by the MySQL backup and behold – it’s text! How great is that!? Not some cryptic gibberish like a SQL Server database backup file format.

When looking at the file a little, right there near the top I found the issue. The MySQL backup files by default assume you want to restore to the exact same file name. So then have this line:

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;

In that line the database that I restored from was actually named “test”. As you can see, it checks for the existence of the database and if it doesn’t exist, it creates the database. Well, in this case I didn’t want that database created and my user didn’t have permissions to perform that action anyway.

So I changed the name of the old database (“test”) to match the name I wanted for the new database (“newTest”).

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `newTest` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;

Great – one error avoided! But thankfully, before existing the .sql file, I noticed the very next line in the file:

USE `test`;

Well, that’s no good. That’s going to use the ORIGINAL database that I performed the restore from. Yikes. If my user had permissions to that database it would have overwritten the original. Not good at all. So, let’s change that…

USE `newTest`;

I did a quick scan through the rest of the file and nothing stood out to me as an issue. I performed the restore (in this case using MySQL Workbench but any tool – even a command line – would have worked fine) and everything went nice and smoothly. Like magic I now have the data from the “test” database restored to my new database named “newTest”.

I hope this is helpful! Cheers, and happy hosting!

Windows Server 2012 Start Screen

The “hover the mouse cursor” trick to get to the Windows Server 2012 Start Screen seems to never work well for me. I wind up spending a ton of time moving my mouse all around to various positions on the screen hoping for that elusive pop-up so that I can get to my common feature controls.

Well, no move hovering for me! I can’t believe it has taken this long, but I just found out today that just pressing the Windows Key on the keyboard jumps straight to the Start Screen.

Yeah me! This solves a ton of frustration and is going to make working with Windows Server 2012 much more productive for me. Try it out for yourself.

Performing Offline installations with WPI Command line tool

Performing application installs on a server that does not have internet connectivity used to be a difficult thing to do. You had to locate and download not only the main application, but any dependencies that would be needed to complete the install. Without an easy way to determine these dependencies, you could be stuck in an endless loop of attempting the install, getting an error, locating the necessary download for the missing files, and starting the process over again. Well, that can be a thing of the past now. The command line Web Platform Install allows you to setup an offline cache that contains not only the application but also any dependencies that are required to successfully install the application. Check out my full blog post about this very subject here:

Using Web Platform Installer command line tool to perform offline installs

~Terri Donahue of OrcsWeb

Implementing Application Initialization on IIS 7.5

Another great post by Terri over at OrcsWeb that I think you’ll find beneficial. Here’s a brief intro and a link to the full post…

Microsoft has released a new module for IIS 7.5 which provides the ability to ‘warm-up’ an application and provide a ‘pretty’ page to the end-user until the application is fully loaded and ready to serve content. It is difficult to determine that this module has been installed without checking your Programs and Features or Web Platform Installer. This post will explain how to implement this functionality on IIS 7.5…

http://www.orcsweb.com/blog/terri/implementing-application-initialization-on-iis-7-5/

Happy hosting!

Orchard: Custom Content in Sub-Folders

Orchard doesn’t seem to like anything in it’s web root except for it’s own content. Try it out – create a folder (I created /TestContent/) and then put a test from there (I created test.html) and try to access it. You’ll get a 404 error. Orchard “traps” all requests and effectively kills them if it doesn’t like them. That’s a bummer though if you want to drop some custom content on your site somewhere for some reason. Let’s see what we can do about it.

I created a default Orchard site. No changes and running the default recipe selected during the initial configuration.

I created a folder named “TestContent” so that it would be available at <orchardsite>/TestContent/

I created a simple HTML file named “test.html” so that it would be available at <orchardsite>/TestContent/test.html

I confirmed that I got a 404 error trying to access the file.

OK. So now let’s see what we can do to fix this issue. There was a lot of research and testing for a solution and I spare you those details and just show how I got past the error.

I surrounded <system.web> and <system.webServer> with location tags to prevent the settings from pushing to all subfolders…

<location inheritInChildApplications="false">
  <system.web>
    ...
  </system.web>
</location>
...
<location inheritInChildApplications="false">
  <system.webServer>
    ...
  </system.webServer>
</location>

I also converted the /TestContent/ folder to an application in IIS. This can be done via many hosting control panels or directly through IIS (either on-server or via the IIS7 Remote Management tool).

Convert a folder an to application in IIS

Great, now my test URL works! But it seems also that the formatting within Orchard has broken. So…

I added another section to the web.config file. This time just below the ending location tag that I wrapped around the system.webServer section.

...
</system.webServer>
</location>
<!--
EDIT: Adding this next section to "fix" the Orchard formatting
-->
 <location path="Themes">
   <system.webServer>
     <validation validateIntegratedModeConfiguration="false" />
     <handlers accessPolicy="Script">
       <remove name="StaticFile" />
     </handlers>
   </system.webServer>
 </location>
 <location path="Core">
   <system.webServer>
     <validation validateIntegratedModeConfiguration="false" />
     <handlers accessPolicy="Script">
       <remove name="StaticFile" />
     </handlers>
   </system.webServer>
 </location>
 <location path="Media">
   <system.webServer>
     <validation validateIntegratedModeConfiguration="false" />
     <handlers accessPolicy="Script">
       <remove name="StaticFile" />
     </handlers>
   </system.webServer>
 </location>
 <location path="Modules">
   <system.webServer>
     <validation validateIntegratedModeConfiguration="false" />
     <handlers accessPolicy="Script">
       <remove name="StaticFile" />
     </handlers>
   </system.webServer>
 </location>
<!--
EDIT: Adding the above section to "fix" the Orchard formatting
-->
 <runtime>
...

And then the Orchard formatting started working again… And the test page in the test folder still worked!

Problem solved? I think so. It seems that this solution works great for me. If you have a different experience with this solution please let a comment and share with the world.

Happy hosting!