Please Note, it’s been pointed out that I need to make it clear that this covers version 5.2, the developer release, of MySQL Workbench. The principles still apply to 5.1, but it’s a different process that I’ve not documented at all. Apologies for any confusion.
This is a slight departure from our usual posts as it’s not about WordPress. However, if you’re developing with WordPress on a Windows PC there’s a good chance you’re using XAMPP as your platform.
I always liked the MySQL Administrator and MySQL Query Browser tools, but these have recently been deprecated and will not be updated any more. Instead, MySQL have released the MySQL Workbench, which is an all-in-one style DB tool that includes query browsing, database management and, interestingly, an entity relationship modeller. The latter is useful if you’re designing databases. In WordPress development you don’t do too much of that as it’s designed as a database light application. A shame, because a better DB structure would really extend its power and reduce the frankly vast amount of code that’s invoked. But that’s for another conversation!
Anyway, you’ll get the Workbench application and then find that it’s far harder to get going than the old tools. But don’t be put off, once you work out a few simple steps you’ll be off.
It’s worth noting that this is as new to me as it is to you – there may be better ways to do this, and I’ve made certain assumptions about how you use XAMPP. If you have any feedback, please comment below!
Create a New Server Instance
Start Workbench and you’ll be presented with a dashboard. Select New Server Instance.
Host machine is LocalHost
OS is Windows
You’ll need to check which version of MySQL you have installed – 5 or 5.1
Don’t Worry About the Error
XAMPP uses a .cnf file, not .ini No idea why, just the way they’ve compiled it, I guess. Remember, we’re not running MySQL from a standard build. Just click next.
Click and Open Connection Manager
Create a Connection Called localhost
Assuming you have the default XAMPP for development purposes then you can use the settings exactly as above. If you’ve assigned root a password you’ll need to completely the fields appropriately. Click Test Connection to make sure all is well. I like to use the Local Socket/Pipe, but you can use TCP/IP also.
The next step in the wizard will test the connection. All should be well and if not you’ve made a mistake.
This is the first point where you deviate from ‘normal’. If you click check path before setting it correctly, nothing will work. So, you need to know where XAMPP is installed. If it’s in the root of your T: drive as it is for our dev machines, then you need to enter the following path: T:\xampp\mysql\bin\my.cnf Change this according to where you placed XAMPP. If you can’t work this path out, maybe you should try a different vocation?
Commands to Manage MySQL Server
This is where it gets a little more fun. The first two are quite easy to work out, but the third is quite different to the default. Maybe there’s a better command, but it was the best I could think of at the time.
As you can see, the commands are:
T:\xampp\mysql\bin\mysqld --defaults-file=T:\xampp\mysql\bin\my.cnf --standalone --console T:\xampp\mysql\bin\mysqladmin --user=pma --password= shutdown mysqladmin --user=pma --password= ping | findstr alive
You may also want to run the commands in the context of administrator in many cases, but I don’t run on my machine as administrator (I’m security conscious) and don’t have the need to run these as admin, so it’s not strictly necessary to tick the box. But for a development machine this isn’t a worry either way.
Name the Instance
Finish off the wizard and you’ll have a new instance. As long as you start MySQL in advance with XAMPP, it will work as expected. Read the note below for more information on why.
A Note About Starting and Stopping
I have to admit that with the current settings I always start MySQL from the XAMPP control panel or shortcuts. If I stop MySQL from the Workbench it can stop it, but it will never notice that it’s stopped. This is less of an issue when you run MySQL as a service, and you can use the default commands given by the wizard, but running Apache and MySQL as a service can be a painful approach with XAMPP so few people bother. If I can find time to work out a slicker approach, or you can tell me of one, then I’ll update this guide.
I hope this guide has been useful. Thanks for reading!