<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Blog Easy &#187; Database</title>
	<atom:link href="http://theblogeasy.com/tag/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://theblogeasy.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 21 Jan 2010 17:10:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Single Sign-on for a WordPress Blog and BBPress Forum</title>
		<link>http://theblogeasy.com/2009/05/10/single-sign-on-for-a-wordpress-blog-and-bbpress-forum/</link>
		<comments>http://theblogeasy.com/2009/05/10/single-sign-on-for-a-wordpress-blog-and-bbpress-forum/#comments</comments>
		<pubDate>Sun, 10 May 2009 14:56:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[bbPress]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Expert]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://theblogeasy.com/?p=194</guid>
		<description><![CDATA[I recently experimented with single sign-on for an existing WordPress blog (2.7.1) and BBPress forum (0.9.4). The two sites were already visually integrated, but behind the scenes everything, including user logins, was separate. With some help from BobbyH (webmaster at Weddingbee.com) and a lot of digging into the BBPress forums, things worked out well and [...]]]></description>
			<content:encoded><![CDATA[<p>I recently experimented with single sign-on for an existing WordPress blog (2.7.1) and BBPress forum (0.9.4). The two sites were already visually integrated, but behind the scenes everything, including user logins, was separate. With some help from BobbyH (webmaster at <a href="http://www.weddingbee.com/" target="_self">Weddingbee.com</a>) and a lot of digging into <a href="http://bbpress.org/forums/tags/integration" target="_self">the BBPress forums</a>, things worked out well and now users have a single login across both blog and forum.</p>
<p>&#8220;Reverse&#8221; integration is the situation where you have an existing WordPress blog and BBPress forum that you would like to integrate. The (by far) simpler option, referred to as &#8220;normal&#8221; integration, is to set up them up as integrated from the start, or even with an existing blog and a brand new forum. There is a great description of these options on the BBPress forum in <a href="http://bbpress.org/forums/topic/wordpress-and-bbpress-integration-101" target="_self">this thread</a>, and <a href="http://bbpress.org/forums/topic/basic-integration-screencast" target="_self">this screencast</a>.</p>
<p>There is very little description of the more complicated reverse integration scenario, so I thought I would lay out the steps here. Most of them (all but the final two) are database operations. I used <em>phpMyAdmin</em> to do these operations (your host probably provides this tool), but you could use whatever tool you have for MySQL admin. You could even do it directly from the command line.</p>
<p>My basic approach here is to use the WordPress database to hold one set of master tables for the user information, and to point BBPress to these tables. I use the BBPress tables as the starting point for these master tables because the forum has thousands of users. I choose to keep <em>only the user tables</em> in the same database. The rest of the BBPress data (e.g. the posts themselves) are still kept in the separate BBPress database.</p>
<p>So the high level steps are:</p>
<ul>
<li>Copy the BBPress user tables into the WordPress database</li>
<li>Replace the WordPress user tables with these new user tables</li>
<li>Modify the new tables so that they are usable by WordPress</li>
<li>Map the old WordPress users to users in the new tables</li>
<li>Set things up to do cookie sharing correctly so people logged into the blog transition seamlessly into the forum and vice versa.</li>
</ul>
<p>Here are the steps in more detail:</p>
<ol>
<li>I didn&#8217;t need to do backups because I was using a test site, but if you are trying this, don&#8217;t go any further without full backups of everything.</li>
<li>Copied the &#8220;bb_users&#8221; and &#8220;bb_usermeta&#8221; tables from the BBPress database to the WordPress database. I was a bit worried that the row sizes weren&#8217;t exactly the same in the destination copy, but as it turns out, that wasn&#8217;t an issue.</li>
<li>Added a &#8220;user_activation_key&#8221; field to the copy of &#8220;bb_users&#8221; to ensure that the schema matched my current &#8220;wp-users&#8221; table in the WordPress database.</li>
<li>Renamed the &#8220;wp_users&#8221; and &#8220;wp_usermeta&#8221; tables to &#8220;wp_users_old&#8221; and &#8220;wp_usermeta_old&#8221; respectively.</li>
<li>Renamed the new &#8220;bb_users&#8221; and &#8220;bb_usermeta&#8221; tables to &#8220;wp_users&#8221; and &#8220;wp_usermeta&#8221; respectively.</li>
<li>Added WordPress admin rights and metadata to the new admin user. To do this I ran the following query: <code>INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES ('1', 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');</code></li>
<li>Added WordPress user metadata for the rest of the users (since I&#8217;m using the<br />
BBPress user tables as the starting point they know nothing about WP capabilities). Here is the query:<code> INSERT INTO wp_usermeta (user_id, meta_key, meta_value) SELECT user_id, 'wp_capabilities' AS meta_key, 'a:1:{s:10:"subscriber";b:1;}' AS meta_value from wp_usermeta WHERE user_id NOT IN (SELECT user_id from wp_usermeta WHERE meta_key = 'wp_capabilities') GROUP BY user_id;</code></li>
<li>Changed the user_id references in the &#8220;wp_posts&#8221; and &#8220;wp_comments&#8221; tables so that they pointed to the correct users (you need to do this because equivalent users don&#8217;t necessarily have the same ID in the previously separate WordPress and BBPress databases). Here are the queries I ran:<code>UPDATE wp_posts SET post_author=NEW_ID WHERE post_author=OLD_ID<br />
UPDATE wp_comments SET user_id=NEW_ID WHERE user_id=OLD_ID<br />
</code>NOTE that you need to think carefully about the order in which you do these changes. You don&#8217;t want to change a user&#8217;s ID to one that already exists in the WordPress table.</li>
<li>Installed <a href="http://superann.com/2009/02/26/wordpress-26-27-bbpress-09-cookie-integration-plugin/" target="_self">superann&#8217;s plugin</a> to downgrade WP 2.7.1&#8242;s cookie handling for compatibility with BBP 0.9.4</li>
<li>Told BBPress to find its user data in the new WordPress user tables. This is done in the BBPress admin page for WordPress integration: [...]/bb-admin/options-wordpress.php. You need to follow the instructions carefully. In particular, note that the WordPress database secret should be copied from the current WordPress setting and not vice versa.</li>
</ol>
<p>This is not something to do in a rush. I checked the results of each step carefully before moving on. This included browsing the database and, later in the process, logging in to the blog and forum to check whether things were working as expected.</p>
<p>And the job is not complete. I can now log in users on either blog or forum and they are automatically logged in when they transition to the other. If they log off on either side, they are logged of from both. What I still need to do is create a login panel that is visible from both blog and forum. Right now, users can only log in on the forum side.</p>
<p>NOTE:</p>
<ul>
<li>This integration approach worked for me, but your mileage may vary. There are many permutations for the configuration of WordPress and BBPress and I&#8217;ve made no attempt to present a completely general solution with the steps above.</li>
<li>Operating directly on your database is not for the faint of heart, so only tackle this if you are confident with phpMyAdmin, or if you are experimenting on a test site.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://theblogeasy.com/2009/05/10/single-sign-on-for-a-wordpress-blog-and-bbpress-forum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reset your Admin Password in the WordPress Database</title>
		<link>http://theblogeasy.com/2008/09/23/reset-your-admin-password-in-the-wordpress-database/</link>
		<comments>http://theblogeasy.com/2008/09/23/reset-your-admin-password-in-the-wordpress-database/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 12:22:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Intermediate]]></category>

		<guid isPermaLink="false">http://theblogeasy.com/?p=183</guid>
		<description><![CDATA[Like most systems that require password authentication, WordPress will help you out if you forget your password. Clicking the &#8220;lost your password&#8221; link at the login page will take you through a sequence of steps that ultimately sends a new password to the email address associated with your WordPress account. But what if your WordPress [...]]]></description>
			<content:encoded><![CDATA[<p>Like most systems that require password authentication, WordPress will help you out if you forget your password. Clicking the &#8220;lost your password&#8221; link at the login page will take you through a sequence of steps that ultimately sends a new password to the email address associated with your WordPress account.</p>
<p>But what if your WordPress installation can&#8217;t send email? This is the case with my development server, so recently when I lost the password I had to do a manual reset in the WordPress database using phpMyAdmin. Here are the steps:</p>
<ol>
<li>Start phpMyAdmin</li>
<li>Select your WordPress database in the sidebar on the left</li>
<li>Select the &#8220;wp-users&#8221; table in the sidebar on the left</li>
<li>Select the &#8220;Browse&#8221; tab at the top of the page</li>
<li>Click the pencil icon to edit the admin entry</li>
<li>Enter a new password in the &#8220;Value&#8221; field (don&#8217;t press &#8220;Go&#8221; yet)</li>
<li>Set the &#8220;Function&#8221; field to &#8220;MD5&#8243;</li>
<li>Press the &#8220;Go&#8221; button</li>
</ol>
<p>Done. Step 7 is the tricky one. MD5 is the password encryption that WordPress uses in order to prevent people from seeing the passwords if they somehow gain access to your database. </p>
]]></content:encoded>
			<wfw:commentRss>http://theblogeasy.com/2008/09/23/reset-your-admin-password-in-the-wordpress-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replicate your bbPress Forum Locally for Development</title>
		<link>http://theblogeasy.com/2008/08/17/replicate-your-bbpress-forum-locally-for-development/</link>
		<comments>http://theblogeasy.com/2008/08/17/replicate-your-bbpress-forum-locally-for-development/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 00:09:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[bbPress]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Intermediate]]></category>

		<guid isPermaLink="false">http://theblogeasy.com/?p=142</guid>
		<description><![CDATA[One part of setting up the YLF forum development server did not run very smoothly: replicating the database. I wanted to get a full version of the current YLF forum with all 20,272 posts by 1214 users. There is no backup or import/export functionality currently built in to bbPress (or available as a plug-in), so [...]]]></description>
			<content:encoded><![CDATA[<p>One part of setting up the YLF forum development server did not run very smoothly: replicating the database. I wanted to get a full version of the current YLF forum with all 20,272 posts by 1214 users. There is no backup or import/export functionality currently built in to bbPress (or available as a plug-in), so I needed to (1) do a database backup and (2) upload the backup to the new local database on my development server.</p>
<p><strong>Export your production database</strong>. There are many ways to do this, but the most common is probably the tool &#8220;phpMyAdmin&#8221;. Most hosting services provide access to phpMyAdmin, and it is also part of the WampServer installation that I use on my local webserver. Since WordPress and bbPress have so much in common, I thought it would be wise to follow the <a href="http://codex.wordpress.org/Backing_Up_Your_Database#Backup_Process_with_phpMyAdmin">WordPress steps for creating a database backup using phpMyAdmin</a>. In particular, steps 1 through 7 worked just fine.</p>
<p>Step 8 is where I had my first problem. Our bbPress database is too big to be saved to a file, and would get cut off after the first 256 posts. For some reason you can get the full database contents by unchecking &#8220;Save as File&#8221; in the phpMyAdmin &#8220;Export&#8221; form. The contents are then displayed in a text area.</p>
<p><strong>Copy it into a text file</strong>. I got the idea of pasting the contents of the textarea into a text file <a href="http://blogs.techrepublic.com.com/programming-and-development/?p=557">from Rex</a>. Since it is a text area with over 10MB of text, it is a little unwieldy, but usable nonetheless.</p>
<ul>
<li>CTRL-A to select all in the text area, then wait a minute for this to register.</li>
<li>CTRL-C to copy all that text, then wait another minute or so.</li>
<li>CTRL-V in a text editor to paste all the text into the file.</li>
</ul>
<p>So far, so good. Unfortunately, things didn&#8217;t go as well when I used phpMyAdmin on the local server to Import the file. There were several odd syntax errors. After some experimentation I started to suspect the text encoding of the file was off. I had been using <a href="http://notepad-plus.sourceforge.net/uk/site.htm">Notepad++</a> (a great free editor). To cut a long story short, I switched to trusty Notepad and when saving the file I specified &#8220;UTF encoding&#8221; in the Notepad &#8220;File Save As&#8221; dialog box.</p>
<p><strong>Import the text file into your local database</strong>. With the database backed up in a UTF-8 encoded text file, the next step is to fire up phpMyAdmin on the local server, load the bbPress database and go to the &#8220;Import&#8221; form. Since we have a large database, I needed to take a few extra steps to ensure that phpMyAdmin loaded the file. These are the same steps that you need to take before <a href="http://theblogeasy.com/2008/08/09/import-a-large-2mb-wordpress-blog/">importing a large WordPress blog</a>, namely, setting the following variables in your &#8220;php.ini&#8221; file:</p>
<p><code>upload_max_filesize = 20M<br />
post_max_size = 20M<br />
max_execution_time = 200<br />
max_input_time = 200</code></p>
<p>Voila. The database contents were imported without any problems.</p>
<p>One small note: If your database had allready been configured by the bbPress install, then you need to go into phpMyAdmin <strong>on your local server</strong> and delete the existing tables to make way for the tables that will be restored from your backup. <span style="color: #ff0000;"><strong>Please, please be careful</strong>. It would be all too easy to get confused and delete the tables in the wrong phpMyAdmin window, that is, the one on your production database. Bye bye forum.</span> </p>
]]></content:encoded>
			<wfw:commentRss>http://theblogeasy.com/2008/08/17/replicate-your-bbpress-forum-locally-for-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database Errors with a Local Install of bbPress 0.8.3</title>
		<link>http://theblogeasy.com/2008/08/17/database-errors-with-a-local-install-of-bbpress-083/</link>
		<comments>http://theblogeasy.com/2008/08/17/database-errors-with-a-local-install-of-bbpress-083/#comments</comments>
		<pubDate>Sun, 17 Aug 2008 18:20:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[bbPress]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Intermediate]]></category>

		<guid isPermaLink="false">http://theblogeasy.com/?p=120</guid>
		<description><![CDATA[This is filed under the heading &#8220;I don&#8217;t know why the solution works, but it does, and that&#8217;s good enough for me&#8221;. The YLF forum is currently based on bbPress 0.8.3 (great forum system, more on that in future posts). I was setting up a development server to test some new features and hit a [...]]]></description>
			<content:encoded><![CDATA[<p>This is filed under the heading &#8220;I don&#8217;t know why the solution works, but it does, and that&#8217;s good enough for me&#8221;.</p>
<p>The YLF forum is currently based on bbPress 0.8.3 (great forum system, more on that in future posts). I was setting up a development server to test some new features and hit a strange error. For the record, my server is using WampServer 2.0c on a Vista SP1 PC. WampServer is great if you have a LAMP (Linux OS, Apache webserver, MySQL database, and PHP) production server and want an equivalent setup on your local Windows PC.</p>
<p>During the bbPress install, which is normally just as simple as <a href="http://theblogeasy.com/2008/07/26/the-blog-easy/">the WordPress install</a>, I got the following database warnings:</p>
<p><code>Warning: mysql_get_server_info() [function.mysql-get-server-info]: Access denied for user ‘ODBC’@'localhost’ (using password: NO) in C:\xampp\htdocs\bbpress\bb-includes\db-mysqli.php on line 80</code></p>
<p><code>Warning: mysql_get_server_info() [function.mysql-get-server-info]: A link to the server could not be established in C:\xampplite\htdocs\bbpress\bb-includes\db-mysqli.php on line 80</code></p>
<p>Who exactly is &#8220;ODBC&#8221;, and why is he trying to access my database without a password? After much futzing with the database settings and the BBPress config, I starting looking around the web for a solution. Fortunately, it wasn&#8217;t long before <a href="http://www.refueled.net/install-bbpress-locally/">I found one</a>. No explanation for why it works, but it does.</p>
<p>In the file &#8220;bbincludes/db-mysqli.php&#8221;, change&#8230;</p>
<p><code>if ( !empty($this-&gt;charset) &amp;&amp; version_compare( mysql_get_server_info(), '4.1.0', '&gt;=') )<br />
$this-&gt;query( "SET NAMES '$this-&gt;charset'" );</code></p>
<p>to&#8230;</p>
<p><code>if ( !empty($this-&gt;charset) &amp;&amp; version_compare( mysqli_get_server_info( $this-&gt;$dbhname ), '4.1.0', '&gt;=' ) )<br />
$this-&gt;query( "SET NAMES '$this-&gt;charset'" );</code></p>
<p>Now, this does involve modifying a file in the bbPress distribution, which I would normally avoid. But in this case I just want the development server up and running asap, so I will live with the hack. </p>
]]></content:encoded>
			<wfw:commentRss>http://theblogeasy.com/2008/08/17/database-errors-with-a-local-install-of-bbpress-083/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
