MariaDB & HeidiSQL - introduction

Making a database in HeidiSQL
When you open HeidiSQL, you will get the session manager.

This is what it looks like in November 2022, but it has looked this way for years.
I have my own site and some sites for a friend of mine in addition to - that's local database. That user is made while you install MariaDB, and is the server we are going to connect to. The username is root and I have configured it with no password. Don't do that! Well, for this course we do that, but it's a terrible habit.

This is made for this course, so there is no danger. I am not giving away this to anyone and it's not for use on the Internet, something Python is excellent for, by the way. But we're not doing that - we're on one desktop, so security is not so important.

In production, I'd make a different user with only the permissions needed for the task. Then I'd give root a long scrabbled password, that I'd save in my password vault, so even I wouldn't know it. Something like this YZBH$rlOemfCeE3454#Bdyf5 would be suitable. The user for the programme (not root) would have a similar password, as no one's going to write the password. It will be copied into the code for opening the database.

This is how HeidiSQL looks like once you get in. is our server.
Right click on and then choose Create new -> Database. Now, fill in the form and click «OK». As you can see, my server is set to use latin_1_swedish_ci by default, but I, that am Norwegian want the utf8mb4_danish_ci since we share the encoding with the Danes so the encoding for ÆØÅæøå will be correct when we read it back out.
Then you must create a table by right clicking on the database and click Create New -> Table. In the «Name» field, set the name for the table, then, at the Columns below, press Add.
The first column is the ID of the record I'ts a bit special and i always call it ID with capitals. It is of type «Int» and the default value is «AUTO_INCREMENT». And we'll do more with it... Right click on the «ID» column choose Create new index -> PRIMARY To make this this tables primary key. The table must have one.
We add one more column, called Text and of type TEXT. There is no need to set any default for this one. Press save to commit the changes.
Click on the «Data» tab, and then the green and white «+» Just ignore the (NULL). That's the ID, that will add a unique number by itself. The Text -field is the one we're going to edit.
If you click slowly twice on the field, you will get a button with three dots on. Click that button! You will then get an editor window up (only partly shown). In there you copy my Loren Ipsum -file, that I generated on this page. It's just one paragraph, but way to big for our programme. We'll fix that in the next few lessons. Just open the Loren Ipsum file in an editor and copy the whole shabang Close the window and it will ask if you want to use the information added. After that, click somewhere in the column window - the white field, to save the info into the database. You will se the red triangle in the corner of the Text field disappear, so you know the actual database has been updated.

Not much programming in this session, but next session will be full of it - I promise.

Have a gorgeous day!

« First -- Previous -- Next -- Last »