diff --git a/wp-settings.php b/wp-settings.php
index a22273905a..f86ae86e71 100644
--- a/wp-settings.php
+++ b/wp-settings.php
@@ -100,6 +100,9 @@ else
// $table_prefix is deprecated as of 2.1
$wpdb->prefix = $table_prefix;
+if ( preg_match('|[^a-z0-9_]|i', $wpdb->prefix) && !file_exists(ABSPATH . 'wp-content/db.php') )
+ die(__('ERROR: $table_prefix
in wp-config.php
can only contain numbers, letters, and underscores.'));
+
// Table names
$wpdb->posts = $wpdb->prefix . 'posts';
$wpdb->users = $wpdb->prefix . 'users';