Lampwrights Forum

Lampwrights Forum (http://www.lampwrights.com/index.php)
-   vBulletin Talk (http://www.lampwrights.com/forumdisplay.php?f=12)
-   -   Add Prefix To Existing Vbulletin Tables (http://www.lampwrights.com/showthread.php?t=60)

Jeff 02-16-2011 11:09 AM

Add Prefix To Existing Vbulletin Tables
 
If you never used prefixes for your MySQL tables on your vbulletin install and now you want to, here is a little script that will rename all the tables with the desired prefix. You must ONLY RUN THIS SCRIPT ONCE! Upload it to your forum root. After you run it, DELETE IT.

The only thing you can define is the prefix.

Code:

<?php

$prefix = 'vb_';

require_once('./global.php');

$rows = $vbulletin->db->query("SHOW TABLES");

while ($row = $vbulletin->db->fetch_array($rows))
{
    $table_name = $row['Tables_in_rib'];

    $vbulletin->db->query("ALTER TABLE $table_name RENAME TO $prefix$table_name ");
}

echo "Completed, delete this file immediately!";

?>


kpmedia 02-21-2011 02:46 AM

Thank you for this. I have a site that needs this done.

34u 08-03-2011 01:24 PM

What is the advantage of having prefixes?

Jeff 08-03-2011 03:13 PM

There is no real advantage. Sometimes people are only allowed 1 mysql database.. Using prefixes avoid collisions with other scripts who may have named their tables the same, or also allows multiple forum installs in one database.

34u 08-03-2011 04:24 PM

Quote:

Originally Posted by Jeff (Post 749)
There is no real advantage. Sometimes people are only allowed 1 mysql database.. Using prefixes avoid collisions with other scripts who may have named their tables the same, or also allows multiple forum installs in one database.

Ok, thanks!

kpmedia 08-30-2011 02:01 AM

Security by obscurity, too.
Harder for an attacker to go after a table if he/she doesn't know the name of it.

BamaStangGuy 11-13-2012 03:47 AM

Got this error:

Code:

Database error in vBulletin 4.2.0:

Invalid SQL:
ALTER TABLE  RENAME TO wf_;

MySQL Error  : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RENAME TO wf_' at line 1
Error Number  : 1064
Request Date  : Tuesday, November 13th 2012 @ 02:46:04 AM
Error Date    : Tuesday, November 13th 2012 @ 02:46:04 AM
Script        : http://www.wiifriends.com/tool.php
Referrer      :
IP Address    : 68.53.229.176
Username      : Brent W
Classname    : vB_Database_MySQLi
MySQL Version : 5.5.28


BamaStangGuy 11-13-2012 04:02 AM

Just an FYI: http://www.yoursitename.com/install/tableprefix.php will rename them.


All times are GMT -4. The time now is 07:42 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2024, vBulletin Solutions, Inc.