Thank you for your question. I can imagine that using the conventional methods for deleting Media Library items would be quite tedious for the large number of items you must remove.
However, it would take much more than a single “sql command line” to properly remove Media Library items. Each item has database entries in more than one database table, and there are often several “attached files” that must be deleted from the file system as well. There are WordPress functions you can call that do all of the required steps for this, and I strongly recommend you find a way to use them.
Deleting 45,000 items will take quite a bit of processing time, and it is very likely you will exceed the time allowed for PHP script execution before all of the items can be deleted. If the script times out in the middle of deleting an item you will be left with some partial or damaged items in the Library.
The most practical solution I can think of would be a small custom plugin that used the appropriate WordPress functions to delete items up to some limit, e.g., 100, 500 or 1,000 items at a time. If that would work for you I can put together an example you can use. Of course, it is up to you to make a database backup before you start and to take responsibility for what happens when the custom plugin is run.
I will leave this topic unresolved until I hear back from you. Thanks for your interest in MLA.