Lampwrights Forum > Other Stuff > vBulletin Talk
Register Community Today's Posts Search

Reply
 
Thread Tools
02-16-2011, 11:09 AM   #1
Jeff
Administrator
 
Jeff's Avatar
 
Join Date: Jul 2010
Posts: 402
Rep Power: 10
Jeff is getting browny points
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!";

?>
Jeff is offline   Reply With Quote

02-21-2011, 02:46 AM   #2
kpmedia
Junior Member
 
Join Date: Jan 2011
Posts: 23
Rep Power: 0
kpmedia is getting browny points
Thank you for this. I have a site that needs this done.
__________________
.
Thanks.
Tip: You can also find me at digitalFAQ.com/forum, if I don't reply here.
kpmedia is offline   Reply With Quote
08-03-2011, 01:24 PM   #3
34u
Junior Member
 
Join Date: Aug 2011
Posts: 4
Rep Power: 0
34u is getting browny points
What is the advantage of having prefixes?
34u is offline   Reply With Quote
08-03-2011, 03:13 PM   #4
Jeff
Administrator
 
Jeff's Avatar
 
Join Date: Jul 2010
Posts: 402
Rep Power: 10
Jeff is getting browny points
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.
Jeff is offline   Reply With Quote
08-03-2011, 04:24 PM   #5
34u
Junior Member
 
Join Date: Aug 2011
Posts: 4
Rep Power: 0
34u is getting browny points
Quote:
Originally Posted by Jeff View Post
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!
34u is offline   Reply With Quote
08-30-2011, 02:01 AM   #6
kpmedia
Junior Member
 
Join Date: Jan 2011
Posts: 23
Rep Power: 0
kpmedia is getting browny points
Security by obscurity, too.
Harder for an attacker to go after a table if he/she doesn't know the name of it.
__________________
.
Thanks.
Tip: You can also find me at digitalFAQ.com/forum, if I don't reply here.
kpmedia is offline   Reply With Quote
11-13-2012, 03:47 AM   #7
BamaStangGuy
Junior Member
 
Join Date: Jul 2012
Posts: 2
Rep Power: 0
BamaStangGuy is getting browny points
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 is offline   Reply With Quote
11-13-2012, 04:02 AM   #8
BamaStangGuy
Junior Member
 
Join Date: Jul 2012
Posts: 2
Rep Power: 0
BamaStangGuy is getting browny points
Just an FYI: http://www.yoursitename.com/install/tableprefix.php will rename them.
BamaStangGuy is offline   Reply With Quote
Reply

Tags

vbulletin code

,

vbulletin other



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 09:03 AM.


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