I think that enforcing a password even for localhost can add a layer of protection, since, with no password the database access would be compromised if the SSH access is itself compromised
The general principle of "defense in depth" would incline one to be extremely wary of having user accounts without passwords at all. The password is a large part of the authentication mechanism; having accounts setup without passwords is akin to having locks without tumblers. I'm in agreement with you here.
Considering that, would it be less safe to allow no password connection to MySQL than having the same password for SSH and for MySQL ?
This is really a question about password re-use. Ostensibly, any password re-use at all is considered a Bad Thing(TM). The mechanism only works because the password is a secret known only to you... and the more frequently you use the secret the less likely it is to remain a secret. However in the real world we have to re-use passwords, either by literally re-using the same password in multiple accounts or by using one master password to secure a list of unique passwords. The answer to this question really depends on your environment and threat model.
As @boris quiroz pointed out, what kind of server is? Who needs access to it? In what other places would the password likely be re-used (i.e., is just for SSH or is also for the nuclear missile control panel? It'd probably be fine to re-use the password for the former, but not for that latter). What do you stand to lose if the password is stolen (i.e., how many eggs are in that single basket)? And what's the price of the data hidden away in your database with the password-less accounts compared that? Then document this process and the reasons underlying your decision. If there's ever an issue in the future, you can justify your choices.
There's no hard and fast rules here. You just need to think about the threat model (what am I protecting and from whom), and decide whether the benefits outweigh the costs. Security is always a compromise, so make sure you buy as much of it with what you give up (say in administrative overhead for example) as you can.
Personally, I would be inclined to use the passwords on both the SSH and MySQL accounts, preferably different ones, but even a re-use here would be better than nothing in my opinion. (Unless you have lots of user accounts, which is an entirely different problem).