Getting started with MySQL

I’ve been coding with RealBudioXo for nearly 20 years but am only now getting around to databases. I have the MySQLCommunityPlugin installed in my plugins folder. I fired up the MySQLExample project but it can’t connect to the database. What to do?


Xojo 2021 r2.1 MacOS 10.14

What is the exception? Is MySQL running?

The exception is “database error”.


What do you mean “is MySQL running”? The documentation says only “In order to use this class, you must have the MySQLCommunityPlugin database plug-in in your plugins folder.” and “When the plug-in is installed, this class becomes available.” I haven’t seen anything about “running” MySQL.

You‘ll need to install the MySQL community server on your machine and run it.

The community server allows multi- user connections. Xojo also has a built-in capacity of creating and accessing single user MySQL databases.

1 Like

Why couldn’t the documentation mention this? smh

The documentation is not always as detailed as one would wish, especially when approaching a new topic. :no_mouth:

Yeah, it was a rhetorical question :slight_smile:

From a licensing POV I would suggest Postgres, that is if you have a choice in the engine.


True. And on Mac, the postgres app is dead easy to install and to work with for development.

+1 for postgres vs mysql.

+1 for postgreSQL

Adding another vote for PostgreSQL. It is free and open source and far more mature.

Thanks for all the Postgre recommendations. I love that they provide excellent PDF documentation (albeit without a bookmarked navigation pane :roll_eyes: ). On the downside, it cannot be installed on my current web host, I’ll have to pay for a VPS and set it up myself, whereas I could turn on MySQL with a couple of cPanel switches. My needs will be very modest - just a handful of users and fairly sparse data.

You can also use MariaDB, which is completely compatible with MySQL and free to use. It is a direct drop in replacement for MySQL.


Use whatever the web host is providing.

1 Like

Hi Julia,

SQLite Database is what you are looking for. It does not require a separate server instance, and is functionally almost the same as MYSQL/MARIA DB to use.

Thanks, @Daniel_Mullins, but I’m not sure. From the SQLite main page: “A good rule of thumb is to avoid using SQLite in situations where the same database will be accessed directly (without an intervening application server) and simultaneously from many computers over a network.” They don’t quantify “many”, and I probably don’t have “many” but I do have multiple users potentially sending and retrieving data from scattered locations. Seems to me client/server is probably best for this application, although your suggestion is a good reminder to me to keep SQLite in mind for self-contained apps. I think I’ve already reinvented that wheel a couple of times now in code.

Hi Julia,

It seemed from the first post you did not know what MYSQL was/is (as in you need to run a server, and the docs did not reflect that). SQLite works more as you expected mysql to work in the first instance, but it is not really suited for multi-user apps, as you pointed out. If your end-users are in scattered locations, you might want to write a simple /api using a Xojo Web App, allowing you to securely send data to/from your server (provided you use SSL, etc), and use whatever backend database you are comfortable using.

Yes, sometimes I’m baffled by the simplest things, but once I’m pointed in the right direction, I’m off to the races :slight_smile: Not interested in writing a web app (although I agree it’d be a good approach) because all my experience is with Xojo desktop, and there’s little time for learning in this project. It’s not a problem for my users to run my desktop app - in fact in most cases they’ll have to, because it’s necessary for controlling hardware at the various locations.

I mean use a Web app as an API to transfer the data instead of exposing the database directly to the internet - as you said the users are in different locations.

E.G. The Desktop app makes a POST call to https://server.location/API/GETDATA using URLConnection (With User/Pass and other data included in the POST data), and the web app responds with the required data sourced from the database. 99% of the code will be the same as you use in desktop apps, except for a HandleURL event and working with the WebRequest/WebResponse