Yes, you can use any database you want with UE4, but you have to use unmanaged C++ libraries to access the database.
Since I have been working on connecting UE4 to a backend database for the past 2 years, I will let you know some of what has worked for me and what hasn’t.
So I started out like you and tried to directly connect Microsoft SQL to my dedicated UE4 server so I could build an MMO. I got it all working, but quickly realized that it doesn’t scale well and was fairly ugly and hard to manage. So then I built a brand new database system that sits behind a web API and is accessed from UE4 using JSON calls. This is working much better now. It also allows me to easily scale up to dozens of servers and create a world of any size I want that can accommodate thousands of players.
The JSON server is built with ASP .NET / MVC 5. I originally used the VaREST plugin to connect to my JSON server, but now I just use direct HTTP calls.
If you have any specific questions, let me know.