-
Shell script to get all WordPress databases and URL’s
Below you will find a simple script that you can use to find all the databases and URL’s associated to wordpress sites in a shared database. This script requires a SQL user with the ability to ‘show databases’ and access to the DB’s you want to query.
The script grabs a list of all the databases on the server then loops through them all retrieving the URL from the wp_options table. The script also takes into consideration the fact the the table might not actually be wp_options (could contain some random characters) so we use a wildcard there.
-
Installing MySQL gem for Ruby 1.9.x
As of this writing, the MYSQL gem cannot be installed by simply doing a GEM INSTALL with ruby 1.9.1. In order to install the gem, follow these easy steps.
First download the mysql gem from rubyforge, and unzip it:
sudo wget https://rubyforge.org/frs/download.php/51087/mysql-ruby-2.8.1.tar.gz sudo tar -xzvf mysql-ruby-2.8.1.tar.gz cd mysql-ruby-2.8.1
-
Finding Duplicate Fields in a Database Table
Occasionally it is necessary to find duplicate fields within a database table. The following query can be used to accomplish this easily.
SELECT *
FROM 'table'
WHERE ('item' IN (SELECT 'item'
FROM 'table'
GROUP BY 'item'
HAVING COUNT(*) > 1))
ORDER BY 'item'
This will list all rows in the desired ‘table’ where the given field (‘item’) is duplicated. This is a great query to use if you want to find duplicate email addresses in a database, or any other field that may be duplicated. -
Setting Up Ubuntu for Rails Development
These are a the procedures we use to setup a PC or VM for development of a ruby on rails application.
First things first, get your install software ready. These instructions are based on the Hardy Heron version of Ubuntu (8.04).
Install the base OS and then fire up the terminal so you can copy and paste the following commands.
So once you have the base installed, make sure your distribution is up to date:
sudo apt-get update
sudo apt-get dist-upgrade -
Installing the Mysql Gem
This is just a self reminder. I always seem to forget the dev package that is required to build the mysql gem. Failure to install this results in all kinds of headaches:
sudo apt-get install libmysqlclient15-dev
Then install the gem and you are all set:
sudo gem install mysql