First, little background on why I’m writing this blog post… I have a client that has a “semi-dedicated” hosting account. In most respects, this account is just a fancy shared hosting account, but they say there are less accounts on the server. The client’s website is on that hosting account. The client also has a server at another location. I have root access to that server, and the client wants to be able to have that server do direct MySQL queries on the website’s database.
Category: MySQL
Switching from MySQL to MariaDB on Ubuntu 14.04
I’ve known about MariaDB for a while, but because I wanted my development machines to match my production environments, I just stayed with MySQL. Today I found out that the production environments switched to MariaDB, so I searched around the internet to find out how to do the switch on my development machines. All are running Ubuntu 14.04, so I thought that as long as I could do it on one, it would be easy to do the rest. Well, that would be the case if there were good instructions somewhere, but I had to piece together a solution that worked for me, as I was getting error messages after following the advice of others.
Easy Backup & Restore a MySQL Database
If you want to make a database backup, it’s better to not use phpMyAdmin, because larger databases will cause that method of backup to fail. Instead, just use mysqldump, which should already be installed if mysql is installed:
#backup mysqldump -u username -ppassword database | gzip > ./dumpfilename.sql.gz #restore gunzip < ./dumpfilename.sql.gz | mysql -u username -ppassword database
MySQL: Convert Column From One Timezone to Another
It’s a pretty common thing to find an app that doesn’t specify to MySQL the timezone that should be used when storing dates and times. Once you’ve fixed that, you may still have a bunch of dates and times that need to be converted.
Virtual Hosts in XAMPP on Windows 7 64-bit
Out of the box XAMPP only displays a single website, which is located in the htdocs directory. If needed, multiple websites can be served by implementing virtual hosts, which only requires editing 2 files. If you’ve been working with another type of server and have not been able to figure this out, don’t worry because it’s really easy.
In the <xampp>/apache/conf/extra directory, you will find a file named http-vhosts.conf. Lets say we want to add a domain named example and that it will be located at C:\xampp183\htdocs\example, here’s what we add to the conf file:
Quick MySQL Datatypes Comparison
Without looking, do you know the difference between MySQL’s text and mediumtext datatypes? How about the difference between int, mediumint, smallint, and tinyint? Unless you’re a Einstein level genius, you’re probably not going to be able to remember the differences between all datatypes, I know I can’t. So, I thought I’d post a comparison of MySQL datatypes. In the future I will probably come back and revise this blog post to show a more complete set of datatypes, but I
‘ll start off with the basics.
Database Bloat by Transients
When I set up this blog on the production server, I thought I was going to be able to eliminate some of the database bloat by removing all of the default themes and installing my custom theme before running the install. My theme has some code in the functions.php file that removes all of the admin dashboard feeds. It didn’t work. WordPress expects there to be an activated theme, and isn’t smart enough to use the only one there is in the themes directory. I probably could have accessed the database and changed the theme before doing the install, but I’m not sure I would have achieved what I set out to do.