Author: Andrew Couch

What is MySQL vs. MariaDB vs. Percona

Illustration by Walker Cahall

Illustration by Walker Cahall

Target Audience

This article assumes you have at least a passing familiarity with databases and some of the terminology around their features.

Introduction

Databases back every application, and there are many choices. MySQL has long been a popular open source choice; however, MariaDB and Percona are two major code forks that can replace MySQL with enhanced features. This article offers a broad comparison of the three.

Read More


How to: Troubleshoot WordPress Plugins by Disabling All of Them at Once

Andrew Couch September 25, 2015 by under Managed Server Hosting 0 Comments

Introduction

One of the aspects of WordPress that has made it so popular as a website framework is the vast number of plugins available to enhance and expand just about every aspect of the base install. Occasionally a plugin doesn’t play well with others. It can do so in such a spectacular way that it crashes your site. Other times a subtle bug can drive you mad looking for the source. In both of these cases, the common advice is to disable all of your plugins and re-enable them one by one to find the culprit. This article talks about how to disable all of your plugins at once even if you cannot get into your admin screen anymore.
.

Prerequisites

– You will need an install of WordPress with access and rights to that directory.

While this tutorial is largely system agnostic, the explanatory screenshots are from Windows.

.

Step 0 – List Which Plugins To Reactivate

Many of us have plugins installed that are inactive. This tutorial will disable all of the plugins at once, so you will need to know which plugins you want to reactivate. If you still have access to your admin screen, make a list of the plugins that are active. If things are broken enough that you are unable to access your admin screen, you’ll get another chance to make that list in Step 3 below.
.

Step 1 – Locate the Plugins Directory

Find the root of your WordPress install on the webserver. The root will have a bunch of .php files and the directories wp-contentwp-admin and wp-includes.

List of files in WordPress root directory

List of files in WordPress root directory

Go into the wp-content directory. Inside is a directory helpfully called . This directory contains all of the PHP code for your plugins, activated or not.
plugins .

Step 2 – Rename the Plugins Directory

Rename the directory from plugins to anything else. I like plugins-disabled, for clarity, but the method works fine with any name. By renaming the directory, we have removed the plugins from where WordPress looks for them without deleting any code.
.

Step 3 – Reload WordPress Admin Screen

This method relies on the way that WordPress checks to see if a plugin’s files exist before attempting to load it. When you reload the Admin screen, WordPress looks for plugins and cannot find them where it expects them to be (because we just renamed the directory). Because WordPress can’t find the plugins, it disables all of them in one fell swoop. You will see errors for each plugin deactivated this way (and here’s where you get that chance to list the plugins which were active if you didn’t or weren’t able to when you started this process). These are one-time errors.

Disable plugin error example in WordPress Admin

Disable plugin error example in WordPress Admin

.

Step 4 – Restore Plugins

Rename the plugins-disabled directory back to plugins, and reload the admin page again. All of your plugins should reappear, but they will be in the deactivated state now.
.

Step 5 – Activate Plugins

Unless you to want to leave your site completely without active plugins, you can now activate them, one-by-one, testing the site until you find your problem.

Shortcut: Remove a Single Plugin

If you know that a specific plugin is causing the problem, you can remove just its directory from the /wp-content/plugins directory to achieve the same effect on a smaller scale.

Atlantic.Net

Atlantic.net offers managed hosting services which include a layer of business-essential managed services to your hosting packages. Contact us today for more information.

.


How to: Using Basic SQL Syntax

Introduction

Behind every great web application is a database of some kind. Many of the widely used database systems (e.g., MySQL, Percona, PostgressSQL, MariaDBMSSQL) use SQL (Structured Query Language) to pull data out and push data in. A lot of modern programming languages provide an ORM (Object-Relational Mapping) layer which loads data directly into code without needing to know SQL, but sometimes you just want to talk to the database directly. While SQL has a lot of keywords and can get very complex, this article goes through the basic CRUD (Create Read Update Delete) constructs.
.

Prerequisites

– A basic understanding of what a database is and how to interact with a database system.

Using Basic SQL Syntax

Some Notes About Dialects and Data Values

Every database system that uses SQL has a slightly different implementation. The differences do not show up in the basic commands that this guide covers, but it is good to know that there are potential differences across systems.

In all of the examples here the SQL keywords are capitalized. While this is a common practice and helps make examples clear, most SQL databases don’t care. The same is true with the line breaks and spacing. SQL can be written all on one line if you prefer, but here we will write statements across multiple lines to help clarify some explanations.

Different data values need to be entered differently depending on data type. Text values need to be encased (escaped) in single quotes. If you happen to have a value that itself contains a single quote, that interior quote needs to be doubled to make sure the statement will run.

WHERE lastname = 'O''niel'

Numeric types, integers, decimals and the like do not need any extra escaping. Boolean values like True and False also do not need to be escaped.

Finally, many SQL implementations use a semicolon as a statement terminator. While this usage isn’t universal, many consider it a best-practice to ensure portabiility of SQL statements across different implementations. This article will use semicolons.

.

SELECT – Reading Data from the Database.

Reading data is the most common task and illustrates the basic structure of a SQL statement nicely. This SELECT is (almost) the most basic SQL statement there is.

SELECT <column_list>
FROM <table>
WHERE <column_name> = <value>;

SELECT, FROM and WHERE are SQL keywords. <column_list> is a comma-separated list of column names that you want to read. It can also be replaced with * to just return all columns of the table. Be aware that * can be quite slow if you have a lot of columns in a very large table.

<table> is the name of the table you want to retrieve data from. <column_name> indicates the name of the column which should contain the <value>.

The WHERE section is optional, but is so useful and idiomatic in SQL that it makes sense to include it. WHERE restricts the data set based on the criteria. Although depicted here with only a single criterion, it is possible to include several criteria with boolean operators AND and OR. See the UPDATE example below for something more complex.

Example:

SELECT common_name, genus, species, type FROM animals WHERE type = 'mammal';

.

UPDATE – Making a Change

Sometimes it isn’t enough to just see what it is in the database. Sometimes you need a change. And when you do, UPDATE is there for you.

UPDATE <table>
SET <column_name> = <value>
WHERE <column_name> = <value>
AND <column_name> = <value>;

Again, UPDATE, SET, and WHERE are SQL keywords. <table> is the name of the table you want to update. Within the SET section, you can include one or more <column_name> = <value> pairs separated by commas. This portion of the statement is where you define the change to be made. The <column_name> will be set with the given <value>.
The WHERE section is optional on UPDATE as well, but leaving it out will update the entire table. Occasionally this is what you want, but most of the time you only want to update a single row or a few rows. In these cases, updating the entire table would be disastrous, so it is good practice to always have a WHERE. This example shows using AND in the WHERE section.

Example:

UPDATE animals SET have_seen = True, common_name='River Otter' WHERE Genus = 'Lontra' AND Species = 'Canadensis';

.

DELETE – Making It Gone

Sometimes you need to remove data from a table. This action is a DELETE.

DELETE FROM <table>
WHERE <column_name> = <value>;

Once again we have our SQL keywords and a <table> defining which table will be deleted from, and a WHERE section defining which rows are to be deleted. Again the WHERE clause is technically optional, but this statement will delete all rows in a table if it is missing.

Example:

DELETE FROM animals WHERE have_seen = False;

.

Delete Tip

One best practice I find for doing manual deletes like this one is to make a SELECT first. The DELETE command shares a lot of structural similarity with SELECT and yet is far more destructive. First write the statement as a SELECT * FROM <table> WHERE <column_name> = <value>; to make sure you know exactly which rows will be affected. Once you are happy with the output, swap out the SELECT * for the DELETE keyword and run it. In the example below, the DELETE statement is commented out. Two dashes -- comment out the rest of the line. This practice can be really helpful when performing DELETEs to keep an accidental run of the query from removing data.

Example:

SELECT *
-- DELETE
FROM animals WHERE have_seen = False;

Note: The -- comments out all text to the end of the line, not the end of the statement. If the FROM animals WHERE have_seen = False were on the same line as -- DELETE, SQL would only see the SELECT * portion of the statement.

.

INSERT – Bringing New Data to the Table

The last piece of this puzzle is adding data into a table. There are two forms of INSERT in classic SQL. The one I’ll cover here allows you to add explicit data into a table.

INSERT INTO <table>(<list_of_column_names>)
VALUES (<list_of_values>);

The INSERT statement looks different than the rest. The <table> again defines the table where the data is going, though here it is followed by a comma-separated <list_of_column_names> enclosed in parentheses. You only have to list the columns for which you have data to enter; however, if the table you are working with has required fields (defined as NOT NULL constraints), you will need to give data for all of those fields to avoid an error.

The VALUES keyword introduces a <list_of_values> inside of parentheses. This list is the list of values to be inserted into the columns you defined above. The listed columns and values need to match each other’s order. The first value will be inserted into the first column name in the list, the second column to the second value and so on. This order in the statement may be different than the order of columns in the target table, but that is fine.

Example:

INSERT INTO animals(common_name, species, genus) VALUES ('Sea Otter', 'Lutris', 'Enhydra');

About Atlantic.Net

Atlantic.Net offers world-class hosting services and solutions, including HIPAA compliant cloud storage hosting. Contact us today for a quote!


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources

We use cookies for advertising, social media and analytics purposes. Read about how we use cookies in our updated Privacy Policy. If you continue to use this site, you consent to our use of cookies and our Privacy Policy.