Solved

How do I search and replace in Phpmyadmin

Posted on 2016-07-23
8
34 Views
Last Modified: 2016-07-29
Hi Phpmyadmin  experts!

I have to search and replace one color with another.  

What is the procedure in Phpmyadmin

To be very specific, the color I have is  #536895    and I want to replace it with #1e4b87

And, yes, I have created and downloaded a backup of the mysql file.

Thanks!

Rowby
0
Comment
Question by:Rowby Goren
8 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 41725892
color of what/where?
please clarify
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 41725900
Hi Guy,

I have a website with colors that are controlled by a mysql database.

So I want to go into Phpmyadmin and do a search and replace of the entire mysql database and anywhere it finds this exact string #536895  
to replace it with this exact string: #1e4b87

Those strings are color codes representing a two different specific color.    So by replacing  #536895   with #1e4b87  will globally replace the first color with the second throughout the entire site.

Rowby
0
 
LVL 22

Assisted Solution

by:Kim Walker
Kim Walker earned 250 total points
ID: 41725904
I'm with Guy Hengel. You're talking about a color which sounds as if you're working in CSS but you'ure using phpMyAdmin which is a database administration tool?

Do you have a table with a column that contains a color that you want to update with a different color? If so, you would need to execute an SQL statement for that.
UPDATE `TableName` SET `ColumnName` = "#1e4b87" WHERE `ColumnName` = "#536895"

Open in new window

BEWARE that this will replace the color in EVERY record that it matches.

And, yes, I have created and downloaded a backup of the mysql file.
How did you do this and what are you referring to as a "mysql file" -- the table? Did you export the table?

This sounds like you're playing with dynamite. Are you sure this is what you want to do and why are you trying to do it in a database? Or have I misunderstood your question? The question is very vague so I could have misinterpreted it.
0
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 250 total points
ID: 41725906
If you expect a general script going through all data of a database, this is not how databases work, a database is not a document you can change with search&replace. There is no aspect of phpMyAdmin helping you with such an idea.

There is SHOW TABLES; to get a list of all tables, similarly SHOW COLUMNS FROM mydb.mytable; to find all columns and types and then you might generate a list of UPDATEs replacing the old with new color in all textual columns.

Most likely you will rather find colors defined in CSS files than in the database of the CMS and you'll be able to change colors in templates or CMS settings in its administration. I'd recommend you rather first find out details about the system and where it stores what info. phpMyAdmin is not your site administration tool, it's 'merely' a database administration tool and such a hack is never a good solution.

Bye, Olaf.

Edit: To give you a hint on how a good CMS or any system works: You have base classes, derived classes, settings files, templates, anything making up the system and you want all this system to work as is and to be updatable. There any change you do in its stem data, in it's base CSS and HTML files, etc, will be lost, if you update the CMS. Such systems therefore typically give you the opportunity to add further files, subclass classes or add your user templates to override or replace defaults, so that happens with additional files or additional data, not replaced, updated or altered with a CMS update.

Alone because of this nature of a good CMS or any other system, you should never even attempt such a hack but read enough documentation to know where and how to change look & feel with what official ways than hack into the data. You'll just have a temporary success and while in this example you don't have to fear much side effects, but more generally speaking this is how you lose warranties.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 41725919
Rowby: Does your site use a CMS like Joomla or similar?
0
 
LVL 9

Author Comment

by:Rowby Goren
ID: 41725951
Hi, all

Latest update.  Thanks for all the suggestions, warning and overall engagement with my "little" switch from one color to another.

And yes, this site is using Joomla.  So the color markup is all over the place. Some is in the database, some is in the global stylesheet.  Some components and modules have stylesheets -- not reflected in the database.

Taking the cautious side here's what I did.

1)  I used Phpmyadmin just to search for the old color.  Then when I found where the color was used, I went into my Joomla installation.  I have a great database replacer (Called DB Replacer by a long time joomla developer, named "Regular Labs".

DB Replacer has many options and can get me to the table level where I did some cautious replacing.  I went to the table where PHpmyadmin told me the old color was, and using DB Replacer fixed the colors in the database -- rather than doing it via Phpmyadmin.

Then I used Joomla's Akeeba backup to backup the site -- specifically all the files in the installation.  I downloaded the backup and extracted it into a folder.  

Then I used Windows Grep to search for "bad" color.   It found the colors in several css files scattered throughout the Joomla files (in components and modules, as well as the overall template for the site.

Then I went back into joomla and used an excellent and amazingly free built in filemanager called "Profiles" and went to each of those 6 files and replaced those colors.

That pretty much found everything -- although I see a few stray colors left on the site-- which I figure was caused by those colors not exactly matching my original search colors. Just a few.  Using Firebug I'll track those culprits down.

Rowby
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 41726000
Joomla supports templates, which
a) define the full look of a site, including any color
b) are located in one template folder

So, I don't know why you would search and replace in so many places to change some color. Not even mentioning data.
You would just adjust all files belonging to the template in its folder. No more, no less.

Bye, Olaf.
0
 
LVL 9

Author Closing Comment

by:Rowby Goren
ID: 41735360
Thanks everyone.  As it turned out my css was all over the place. In the database, assorted files in multiple folders.  Astrogrep was also a big help
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Creating and Managing Databases with phpMyAdmin in cPanel.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now