Al Nyveldt

Adventures in Code and Other Stories

If you are reading this blog regularly, you are now likely tired of the database themes going on this week.  First, it was SQL Server and BlogEngine.  Then VistaDB Express and BlogEngine.NET complete with download.  Today, I’m moving on to MySql.

Let me start this post by admitting right up front that I have almost zero experience with it.  I didn’t even get it installed until last week and that was just to make sure the BlogEngine.NET could work with it.  So instead of completely embarrassing myself by doing a screencast with something I know nothing about, I figured I’d just write up a guide on how to do get started with BlogEngine and MySql and embarrass myself with text.

Requirements

I’m expecting you have BlogEngine.NET installed with the default settings and providers.  If you need help getting to this point, you should check out my initial installation screencast.

Second, I’m expecting you have a MySql database setup and some administration tool to work with.  If you need help getting to this point, I wish you the very best. :)  Actually, I was truly miserable until Ruslan Tur recommended Toad for an admin tool.  This made my experience much, much better.

Creating a Database

You’ll need to create a database or have a database to put the BlogEngine table in.  I have created a script to get the initial tables and data created for you.  Just execute it against the database you want to use for BlogEngine.NET.  Download the script here.

Add the MySQL dll to your bin folder

You’ll need to download the MySQL Connector/NET 5.1, find the MySql.Data.dll, and added to your bin folder.

Update your web.config

I’m including a sample web.config for you to download, but I’ll go through the changes here. (Download Sample web.config.)

First, we need to let BlogEngine know about this new MySQL dll we just added.  This is done by adding the assembly to the list of assemblies and then adding in the system.data section to let BlogEngine know where it will find the MySQL DBProviderFactory.

   1: <system.data>
   2:     <DbProviderFactories>
   3:         <clear />
   4:         <add name="MySQL Data Provider" 
   5:              invariant="MySql.Data.MySqlClient" 
   6:              description=".Net Framework Data Provider for MySQL"  
   7:              type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=5.1.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
   8:     </DbProviderFactories>
   9: </system.data>
  10: <system.web>
  11:     <compilation debug="false">
  12:         <assemblies>
  13:             <add assembly="MySql.Data, Version=5.1.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
  14:             <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  15:             <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  16:             <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  17:             <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  18:             <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  19:             <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  20:             <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
  21:         </assemblies>
  22:     </compilation>
  23:     < ....snip..../>
  24: </system.web>

Then, you will need to add your connection string to your connectionString section.

   1: <connectionStrings>
   2:         <clear/>
   3:         <add name="LocalSqlServer" connectionString="dummy"/>
   4:         <!-- Mono complains if LocalSqlServer isn't specified -->
   5:         <add name="BlogEngine" 
   6:              connectionString="Data Source=MySQLServer;User ID=user;Password=password;persist security info=False;initial catalog=BlogEngine;" 
   7:              providerName="System.Data.SqlClient"/>
   8:         <add name="MySQLDB" 
   9:              connectionString="Server=localhost;Database=blogengine;Uid=beUser;Pwd=beUser;" 
  10:              providerName="MySql.Data.MySqlClient"/>
  11:     </connectionStrings>

Lastly, we need to link up the BlogProvider, the MembershipProvider, the RoleProvider, and the ProfileProvider.  The BlogProvider section is near the top of your web.config in a BlogEngine section.  The other 2 can be found in in succession down much further in the file.

   1: <BlogEngine>
   2:     <blogProvider defaultProvider="DbBlogProvider">
   3:         <providers>
   4:             <add name="XmlBlogProvider" 
   5:                  type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core"/>
   6:             <add name="DbBlogProvider" 
   7:                  type="BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core" 
   8:                  connectionStringName="MySQLDB" 
   9:                  parmPrefix="?"/>
  10:         </providers>
  11:     </blogProvider>
  12: </BlogEngine>

 

   1: <profile enabled="true" defaultProvider="DbProfileProvider" inherits="BlogEngine.Core.Web.AuthorProfile" automaticSaveEnabled="false">
   2:     <providers>
   3:         <add name="XmlProfileProvider" 
   4:              type="BlogEngine.Core.Providers.XmlProfileProvider, BlogEngine.Core"/>
   5:         <add name="DbProfileProvider" 
   6:              type="BlogEngine.Core.Providers.DbProfileProvider, BlogEngine.Core" 
   7:              connectionStringName="MySQLDB" 
   8:              parmPrefix="?" />
   9:     </providers>
  10: </profile>
  11: <membership defaultProvider="DbMembershipProvider">
  12:     <providers>
  13:         <clear/>
  14:         <add name="XmlMembershipProvider" 
  15:              type="BlogEngine.Core.Providers.XmlMembershipProvider, BlogEngine.Core" 
  16:              description="XML membership provider" 
  17:              passwordFormat="Hashed"/>
  18:         <add name="SqlMembershipProvider" 
  19:              type="System.Web.Security.SqlMembershipProvider" 
  20:              connectionStringName="BlogEngine" 
  21:              applicationName="BlogEngine"/>
  22:         <add name="DbMembershipProvider" 
  23:              type="BlogEngine.Core.Providers.DbMembershipProvider, BlogEngine.Core" 
  24:              passwordFormat="Hashed" 
  25:              connectionStringName="MySQLDB" 
  26:              parmPrefix="?" />
  27:     </providers>
  28: </membership>
  29: <roleManager defaultProvider="DbRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".BLOGENGINEROLES">
  30:     <providers>
  31:         <clear/>
  32:         <add name="XmlRoleProvider" 
  33:              type="BlogEngine.Core.Providers.XmlRoleProvider, BlogEngine.Core" 
  34:              description="XML role provider"/>
  35:         <add name="SqlRoleProvider" 
  36:              type="System.Web.Security.SqlRoleProvider" 
  37:              connectionStringName="BlogEngine" 
  38:              applicationName="BlogEngine"/>
  39:         <add name="DbRoleProvider" 
  40:              type="BlogEngine.Core.Providers.DbRoleProvider, BlogEngine.Core" 
  41:              connectionStringName="MySQLDB" 
  42:              parmPrefix="?" />
  43:     </providers>
  44: </roleManager>

Configuration

Once you have these changes made, you can browse out to your web site and you should be greeted by a new welcome message.  Just as with the SQL Server setup, you’ll be missing your widgets.  So you can login with user “admin” and password “admin”.  Add your Administration widget and then refresh your page to see the full menu.

At this point, you should add users and change the admin password.

It really is fairly easy to get set up especially since you can copy and paste the new sections out of my sample web.config.  I also wanted to start that I save a bit of time getting the install script done by starting with the script I found as part of this post by Mr. Wize.  I added the new tables and initial data, but the initial work was done by him.

Capture Now that the latest version of BlogEngine.NET is out, it is easier than ever to get your blog running with VistaDB Express.  I’ve been using VistaDB Express with BlogEngine.NET for a little while now and just love it.  I’ve become a fan of the lightweight, file based database for a single user blog.  I think it is a perfect way to store your blog data.  Enough of my gushing already, let’s get on the real info.

Getting BlogEngine.NET 1.4 to work with VistaDB is super easy, but will require you to upload a few more files.  I’ve put together a new screencast that will walk you through the steps, show you exactly what to do and what changes are being made.

It is incredibly simple however.  You simply download the BlogEngine 1.4 VistaDB Express Pack, unzip it, upload 3 files, and enjoy the goodness that is VistaDB Express and BlogEngine.NET 1.4.  In the screencast, I also take a little time to walk you through the main changes made to the web.config to make this work.

If you are starting a new BlogEngine.NET blog, I strongly recommend it.  If you already have a BlogEngine.NET blog and want to convert over to it, I’ll get to that soon.  I promise. :)

SQLSnip BlogEngine.NET 1.4 supports storing your data pretty much however you’d like.  By default, it will store your data using XML.  However, with a few simple steps you can be running your entire blog off of a database.  Today, I put together a new screencast to show you exactly how to configure your blog to use SQL Server.  For the veterans out there, there is some key changes in BlogEngine.NET 1.4, so it should be worth watching for you as well.

It is important to point out that this screencast starts with BlogEngine.NET 1.4 installed with the default providers.  If you need help getting to that point, please watch the installing BlogEngine.NET 1.4 screencast.

It is important to know that BlogEngine.NET actually has 4 providers that can be configured.

  • Blog Provider – Store posts, pages, settings, etc.
  • Membership Provider – Store user names, passwords, etc.
  • Role Provider – The role the users are in.  (Administrator, Editor)
  • Profile Provider – Information about the users.

This new screencast will walk you through getting the BlogProvider and the ProfileProvider setup using the new DbBlogProvider and DbProfileProvider. 

MembershipSnip For SQL Server, I’d recommend using the SQLMembershipProvider and the SQLRoleProvider that are built in to the .NET Framework.  I made a screencast a while back on getting these set up, so I figured I’d save the effort and just link to it again for setting up these providers.  Nothing has changed in the configuration.

Capture5 I’ve decided to start another series of screencasts to celebrate the new version of BlogEngine.NET.  The best place to start is at the beginning so here is the installing BlogEngine.NET 1.4 screencast.  Hopefully, it will be helpful in getting you up and running quickly.

I mentioned the previous installation screencast in in this screencast.  If you are looking for an example using an older version of IIS, you might want to view this one.  The process is basically the same.

Also, I’d like to add that if you are having trouble with your password, the first time around, an application reset might do the trick. 

If you have questions or need help, please check out the BlogEngine.NET forums.  There are lots of very helpful people and information to be found there.

I’ve decided to stick with just the flash version this time around as I’ve seen minimal usage of the wmv files I’ve made in the past.  If another format is needed, let me know.

Good luck with your BlogEngine.NET installation.

100_5087 This was fairly popular last time around, so I wanted to write this up and make sure it was available right away with the new 1.4 release.  The upgrade process is fairly easy but there are a few things to be aware of.  Hopefully, I’ll cover everything you could possible want to know on your journey from BlogEngine.NET 1.3.x to BlogEngine.NET 1.4.

1. Backup your stuff

If you read this last time, you realize that there is no warranty with my guide and you are strongly encouraged to backup your blog and blog data.

At a minimum, please backup your App_Data folder, any custom themes or extensions you may have, and your web.config especially if you are a database user.

2. Download BlogEngine.NET 1.4 (website)

This is likely the step you have already done.  (If not, get it here.)  Once you have it located on your PC, unzip it.  Right click the folder, go to Properties and remove the Read Only check.  (This step has helped some and has never hurt anyone.)

3. Update your database

If you are using the the MSSQL Provider and have your blog data stored in SQL Server, we have an upgrade script for you to run.  It adds a few more tables and some basic data for them.  The script is found in the Setup folder of the blog and it is labeled MSSQLUpgrade1.4.0.0.sql.  Run this against your BlogEngine database.

4. Configuration… as in Web.Config

If you are a database user, you are going to have to make some updates to the web.config that you are about to upload.

First thing, you will want to add your connection string to the new web.config in the connectionStrings section.

Second, you will notice that the MSSQLBlogProvider is gone.  (Its ok.  It has gone to a better place.)  It has been replaced with the DbBlogProvider.  This is your new friend.  Make sure you have your connection string name marked here and set the DbBlogProvider as your default BlogProvider.  Save your changes.

Capture2 

5. Upload your files

This is a little bit tricker this time around so pay attention.

First, make sure you have a good backup from step #1.  This is really your last chance to do that.

Now, you can upload everything except the App_Data folder.  It is important to note that a few things have moved around and if you just choose to overwrite files, you’ll have some left overs.  These leftovers should not cause problems for you (except noted in the troubleshooting section) but they just take up space, most notably the tiny_mce folder under the admin folder has been moved and can be deleted.

Once you have most files moved up, it is time to go into your app_data folder.  In the downloaded project, you will see two new folders, datastore and profiles.  Upload these to your site as well.  (If you use a database for file storage, it isn’t require, but it is consistent.)

6. Security Update

If you use the default XMLMembership provider to store your passwords, this has been updated in in 1.4.  We had been storing the password in clear text and this is no longer the default.  If you wish to continue with clear text, you can set your XMLMembershipProvider passwordFormat to Clear in the web.config, but this is not recommended.

Since BlogEngine.NET 1.4 is looking for hashed passwords by default, you’ll be unable to log in unless we make a change to your user data.  You’ll need to retrieve your users.xml file from your app_data folder.  You should be able to see your users and passwords listed in the file.  Remove the password from each entry user so it has an blank or empty password and save the file.  Upload your newly edited file to your site when you are done.

Capture

This will cause BlogEngine to allow you to log in with each user using the password “admin” so that you can then change the password to whatever you’d like.  The new password will be hashed.

7. Fire it up

Ok, now that we have everything out there, let’s run it.  Point your browser back to your blog and after a few moment wait as your site compiles, you should see your blog back as you’d expect it.  (If your blog doesn’t come up, see the troubleshooting section below.)

Now that you are up, first log in and use the change password option on your admin menu to change your password to something secure.

8. Check your settings

Everything is done, but it is always a good idea to Check your settings and make sure everything is configured properly.  This would also be a great time to fill in your profile for FOAF support.

Troubleshooting

Hopefully, you are just reading this because you want to see what other poor souls are struggling with.  The typical things that are going to cause trouble are custom themes and extension that were made prior to 1.4.  If you have any installed remove them and try again.  If you are still having trouble, try going into your settings.xml or be_Settings table and changing the default theme to be Standard.

If you are having trouble logging in to your blog, try an application restart.

If you have more tips or additions, please make them in the comments and I’ll update this post.

About

BioPic Hi. My name is Al Nyveldt and I'm a software developer from central Pennsylvania, USA.

I'm on the BlogEngine.NET development team and write on a variety of development related topics. More...

Follow me on Twitter
Contact me via email

Recent Comments

Quote of the Day

"When nothing seems to help, I go look at a stonecutter hammering away at his rock perhaps a hundred times without as much as a crack showing in it. Yet at the hundred and first blow it will split in two, and I know it was not that blow that did it, but all that had gone before."

- Jacob Riis

Sponsor


Recommended Books



Archives


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in