Solved

How do I search and replace in Phpmyadmin

Posted on 2016-07-23
8
70 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 143

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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
 
LVL 110

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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

707 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