So I tried it, and it works. Here's some notes.
mysql -u root -p mrbeardb —port=3306
References
- Linuxize - How to Connect to MySQL through SSH Tunnel
- https://linuxize.com/post/mysql-ssh-tunnel/
So I tried it, and it works. Here's some notes.
There are lots of nice diagrams explaining the difference between the different joins in SQL.
This is going to be a small blurb, on what I did to get this working.
Nothing out of the ordinary, really.And of course allow the user accounts to access mariadb remotely over the network.
Attention! I'm only doing this locally on a testing server! It's not a great idea to run mariadb connections remotely if you do not have to.
Hello, again!
This is just a small blog post on how to backup and restore a MariaDB server, without using MysqlDump, but by directly copying the files in /var/lib/mysql.
First of course we need to shutdown mariadb.
Copying files:
When putting things back, things start to go wrong1.
Copying the files to a new host, causes this:
So, if the below code works, than SELinux is causing the issue:
Now you added mysql_t to permissive, as shown by the below printout:
Turning it back to enforcing, means running:
We need to relabel the new /var/lib/mysql directory:
Checking the current file contexts:
I need to check out MariaBackup2 3, as a better solution for creating backups compared to mysqldump.
I ran into some issues, and I thought I'd document them here.
So changed my persistence.xml and added:
Also:
As the vendor name was not detected, eclipselink switched to a default implementation. The default implementation requires SEQUENCES for the IDENTITY definition.
It turns out the MariaDB implementation of Sequences is not compatible with the standard SQL way of creating sequences.
So I had to add the following property to the JDBC Connection pool:
I recently read [1], and it had a very interesting notion.
The idea is to let the database generate JSON, and provide it straight into your client.
So I decided to find out if MariaDB had some support for this as well.
It does2.
So, it basically was nothing more then calling a NativeQuery on the EntityManager, and returning a concatted resultset with a '['prefix and a ']'postfix and a comma-delimiter and away we go.
The native query looked like the following:
It worked flawlessly!
Caveat: of course, this is only in the case where your middleware (as in this example) really doesn't need to do anything with the result.
I mean, you are going to have to do all checks in the database query.
I think this example shows its strength when you just really want to read a lot of data, and do not need to process it.
Consider the following table "mm_mailtable", containing the following data:
| id | name | toname | whensent | subject | haveread | newmail | |
|---|---|---|---|---|---|---|---|
| 27999 | William | Joe | 2018-03-13 12:41:25 | Golf next week? | 1 | 0 | |
| 28000 | William | Linda | 2018-03-13 12:41:25 | I'm out! | 1 | 0 | |
| 28001 | Linda | William | 2018-03-13 12:41:25 | Okay! | 1 | 0 | |
| 28002 | Joe | William | 2018-03-13 12:41:25 | Sure thing! | 1 | 1 | |
| 28003 | Jim | William | 2018-03-13 12:41:25 | The house | 1 | NULL |
Also consider the following query I found in our source code somewhere.
Let's say we try the query out with "William" as NAME and 0 as NEWMAIL.
We get an old mail to William with "Okay!" as subject.
Let's say we try the query out with "William" as NAME and 1 as NEWMAIL.
We get a new mail to William with "Sure thing!" as subject.
Let's say we try the query out with "William" as NAME and NULL as NEWMAIL.
Now I would expect to get all three entries returned, but the one containing the NULL value for "newmail" is not returned.
It takes some getting used to, but comparing null values is not possible in most databases, as it is undefined (a.k.a.. NULL).
See for more and better explanations the references below.
P.S. in this case, in our database, the column "newmail" should have been defined as "NOT NULL" and given a "DEFAULT" value, to prevent this sort of thing. Apparently it was forgotten.
This should work:
I was just looking for a way to remove tags from strings in a database. MySQL has no support for regular expressions, so I fell back to the old way.
Just writing it down, as I think I might need it later too.
The first one is to determine which ones are to be changed. The second one changes nothing, but outputs the new result. The third one actually changed the data.
I am running MariaDB and I wish to execute sql scripts without all this hassle of entering my password. Of course this carries severe security risks with it, that we need to be aware of and, if possible, mitigate.
It is possible to execute sql scripts via the commandline1, but the problem here is that the password you use is visible in the process list. So this is a security risk.
Let's not do this.
I firstly checked out mysql_config_editor2, which enables you to put the password and other options into an encrypted configuration file. But it turns out that MariaDB does not come with that specific tool. The encryption used seems quite weak, and there's an article about the security issues at [3]. There is also the blogpost at [4] giving some details.
Well, there is always the plan to use the configuration file .my.cnf5, and you can store your mysql or mariadb password in there and everything would be hunky-dory.
The .my.cnf looks like this:
You are no doubt aware that the password is stored in cleartext.
The following security measures should be in place:
There is an example of a my.cnf containing every possible configuration option at /usr/share/mysql/my-large.cnf when you install MariaDB.
“You're correct. For legacy reasons (including compatibility with ODBC, and SQL Server), JDBC's concept of "catalog" maps to MySQL's concept of "databases".- Mark Matthews
Starting in MySQL-4.1, "schema" is an alias for "database", but it doesn't act like a SQL-standard schema, so we don't support the concept in the JDBC driver.”
“Input parameters can only be used in the WHERE clause or HAVING clause of a query.”Apparently JPQL doesn't allow named parameters (or parameters of any kind) outside a WHERE or HAVING clause.