drroot Posted March 17, 2012 Share Posted March 17, 2012 Could we do this from Back Office->Preference->Database? Otherwise what is the safe SQL command to change the database prefix? Thank you. Link to comment Share on other sites More sharing options...
drroot Posted March 17, 2012 Author Share Posted March 17, 2012 Beside of modifying config/settings.inc.php, anywhere else to change? Link to comment Share on other sites More sharing options...
drroot Posted March 17, 2012 Author Share Posted March 17, 2012 Could we use following bash script on the dumped the sql database? #!/bin/sh # # Simple script for setting table prefixes in SQL-dump if [ $# != 2 ]; then cat >&2 << EOH Usage: $0 prefix original_db.sql >prefixed_db.sql - all tables will prefixed with 'prefix' EOH exit 1; fi PRFX=$1; sed "s/^CREATE TABLE /CREATE TABLE $PRFX/i; s/^INSERT INTO /INSERT INTO $PRFX/i; s/^REPLACE /REPLACE $PRFX/i; s/^ALTER TABLE /ALTER TABLE $PRFX/i" $2 Link to comment Share on other sites More sharing options...
newbie2PS Posted July 29, 2013 Share Posted July 29, 2013 Hi drroot, After my store seems getting bad bots and now I'm try to figure things out too. I cam across with this blog http://blog.dh42.com/best-e-commerce-security/. And I have an idea to change the databse prefix too because I ask my hosting to insall prestashop for me. So I wonder if we can change the prefix now after the installation for many months. Have you had the solution yet? Best Regards, Link to comment Share on other sites More sharing options...
vekia Posted July 29, 2013 Share Posted July 29, 2013 well, it is possible but in this case you need an access to some database manager software like phpmyadmin if you've got - you can alter all tables there (change name of the table, which mean that you can change table prefix) after that you have to define new table prefix in the settings.inc.php file (config/sertings.inc.php) you've got there: define('_DB_PREFIX_', 'ps_'); change the value to your new prefix defined in the phpmyadmin (while you altering tables) 1 Link to comment Share on other sites More sharing options...
newbie2PS Posted July 31, 2013 Share Posted July 31, 2013 Dear Vekia, Thank you very much for your reply. I wonder if changing the table prefix will increase the security to prestashop or not? Best, Link to comment Share on other sites More sharing options...
vekia Posted July 31, 2013 Share Posted July 31, 2013 nope, table prefix isnt related to the security 1 Link to comment Share on other sites More sharing options...
newbie2PS Posted July 31, 2013 Share Posted July 31, 2013 Thank you very much, Vekia Link to comment Share on other sites More sharing options...
selsiusx Posted March 3, 2014 Share Posted March 3, 2014 If I change the db prefix in settings.inc.php, still the old prefix is used... (prestashop 1.5.6.2) is ther some cache I need to clear ? Link to comment Share on other sites More sharing options...
vekia Posted March 3, 2014 Share Posted March 3, 2014 you changed also table names? it's necessary to alter these tables and regarding to cache: yes, you have to clear cache and recoimpile entire theme Link to comment Share on other sites More sharing options...
Ivak Posted April 5, 2016 Share Posted April 5, 2016 I've found simple method. Just open .sql file from Notepad ++. Find the first table name. Copy its prefix. Press Ctrl+H. Paste that copied prefix in the "find" text box. Then type "replace" text. Just click replace button once. Then again. Those two files replace without problem. Just press replace all button. It will replace your all prefix according to given condition. Link to comment Share on other sites More sharing options...
lxuancheng Posted June 5, 2017 Share Posted June 5, 2017 My /config/settings.inc.php is empty, where is saved my first prefix configuration? Link to comment Share on other sites More sharing options...
Afriluka Posted February 23, 2021 Share Posted February 23, 2021 (edited) It seems since Prestashop Version 1.7.0.0 it is stored in /app/config/parameters.php Edited February 23, 2021 by Afriluka (see edit history) Link to comment Share on other sites More sharing options...
Afriluka Posted February 23, 2021 Share Posted February 23, 2021 I am using Prestashop 1.7.7.0 and I have changed my prefix from ps_ to a more unique one. I also changed the prefix in the file mentioned above. The Frontoffice is working well. But the backoffice is showing "HTTP ERROR 500". But when I turn the debug mode on, everything seems to work well. Does anyone has an idea what this could mean? And how to fix it? Thank you in advance. Link to comment Share on other sites More sharing options...
daxit_x Posted April 12, 2023 Share Posted April 12, 2023 (edited) Hello I am using prestashop 8.0.2 on PHP 8.1 I tried to change a custom table prefix I used during installation in favour of the default prefix ps_ I got exaclty the same error that Afriluka described in the previous post "The Frontoffice is working well. But the backoffice is showing "HTTP ERROR 500". But when I turn the debug mode on, everything seems to work well. " So it seems that in prestashop 8 changing the tables' prefix, editing the /app/config/parameters.php file, clearing cache and recompile template files is not enough, I searched quite much on the forum, on the docs, in more search engines for some extra information and found none. Does anyone know all what has to be done to change the database tables' prefix in prestashop 8? Thank you Edited April 12, 2023 by daxit_x (see edit history) Link to comment Share on other sites More sharing options...
fazilnlend Posted April 13, 2023 Share Posted April 13, 2023 Hello, logged in phpadmin you can proceed via script (Alter table to rename) or simply proceed as below, click on your database Mark all tables which you want to change the prefix (in the bottom of the main screen you can find a “check all” box). Near the "check all" box, in the drop down list select "Replace prefix". Enter the "From" prefix that you intent to change, Enter the "To" prefix that you want to adopt (including "_" at the end as usual) and submit. into /app/config/parameters.php (prestashop 1.7) or settings.inc.php (prestashop less version) Locate the line "database_prefix" and modify with "YourCurrentPrefix" then save Link to comment Share on other sites More sharing options...
daxit_x Posted April 13, 2023 Share Posted April 13, 2023 Hello Yes fazilnlend, that procedure you describe is correct, but not complete at present day with PS 1.7 and PS 8x. At least from prestashop 1.7.7.0 and definitely in prestashop 8x that procedure is not complete and will cause severe problems as reported e.g. by Afriluka Quote Afriluka - Posted February 23, 2021 I am using Prestashop 1.7.7.0 and I have changed my prefix from ps_ to a more unique one. I also changed the prefix in the file mentioned above. The Frontoffice is working well. But the backoffice is showing "HTTP ERROR 500". But when I turn the debug mode on, everything seems to work well. and as reported now also by myself having very recently done extensive experiments on prestashop 8.0.2 Quote daxit_x - Posted 12 April 2023 I got exaclty the same error that Afriluka described in the previous post "The Frontoffice is working well. But the backoffice is showing "HTTP ERROR 500". But when I turn the debug mode on, everything seems to work well. " So it seems that in prestashop 8 changing the tables' prefix, editing the /app/config/parameters.php file, clearing cache and recompile template files is not enough, I searched quite much on the forum, on the docs, in more search engines for some extra information and found none. I checked if anything regarding the tables prefix could be for any reason be written also inside an any table, as foreseen apparently nothing is written in the database, so I checked the whole filesystem and saw that the tables' prefix is noted also in a lot of files into the folder var/cache/prod, substituting the old prefix with the new prefix in all the files (over 200 files) seemed to have solved the problem, apparently, I am not sure yet. I did some tests and saw no problems except than in relation to a module if debug mode is active on the front office I get a huge error message, but this could be related to that specific module only, I have no clear idea about that yet, I need to do more experiments and check e.g. if autoupgrade continues to work fine after these changes and so on. in that var/cache/prod folder the files contained are all related to "symfony" framework, I have no idea of what that system does there, however at first glance looked alike that dynamically injects code stuff into the live code used by the website, just a guess, I have no real good idea. Another thing I am guessing is that this symfony system cache is not deleted using the usual procedure by clicking the button in the advanced parameters > performance panel, I have no idea of how to reset the cache of this sysmfony system, I would like to do it as I am guessing that could be another way to to solve troubles arising after changing the tables' prefix. Does anyone have more information about these issues? Thank you in advance Link to comment Share on other sites More sharing options...
fazilnlend Posted April 13, 2023 Share Posted April 13, 2023 Hello Daxit_x, Thanks for the feedback. i faced the error 500 (true that it was not after a change of prefix) following different change i made time to time and below are some suggestions : Try to turn off URL rewriting (you can turn on back later) Try to Restore a backup of the .htaccess file that your system was working with before the change made Try to rename (since your shop is ben visited in the same time by customers) then erase these two directories DEV and PROD to clear cache. NB: Always remember to keep a recent backup of the system to be able to restore in case of issues. Link to comment Share on other sites More sharing options...
jetx Posted September 19, 2023 Share Posted September 19, 2023 On 4/13/2023 at 8:27 PM, daxit_x said: in that var/cache/prod folder the files contained are all related to "symfony" framework, I have no idea of what that system does there, however at first glance looked alike that dynamically injects code stuff into the live code used by the website, just a guess, I have no real good idea. Just delete this folder. Simply replace the data prefix using phpmyadmin, edit your parameters file prefix and delete the cache folder (prod). Link to comment Share on other sites More sharing options...
WeMobiles Posted January 29 Share Posted January 29 We faced the same issue in Prestahsop 8.1, to fix that removed the prod and dev folder in var/cache, and then reloaded the browser. that's it. Thank You wemobiles Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now