Is this more or less safe than just adding the username with the password: sha2(username.password).
There is no real difference. Both using plain username and md5(username)
are bad ideas and show a missing understanding of what the salt is used for and how to generate and store it. A salt is used to drastically increase the search space for the attacker in that the same passwords will result in different hashed passwords and thus pre-computing lots of hashed passwords for easy comparison becomes infeasible.
If you use a non-random salt derived from the username (or the username itself) you still increase the search space but not as much as a pure random salt would be used. Since the salt for a hashed password is no secret anyway (see How to store salt?) there are no advantages in using a non-random salt derived from the username compared to a random salt but there are only obvious disadvantages. But, to come back to username
vs. md5(username)
- there is practically no difference in increase of search space because the probability of different usernames resulting in the same hash (i.e. collision) is practically zero. Still, don't use any of these but use a random salt.
Apart from that using sha2(salt,username)
to compute the password hash is a bad idea too because SHA-2 is fast and thus brute-force attacks are easy compared to using a slower hash. See What is the specific reason to prefer bcrypt or PBKDF2 over SHA256-crypt in password hashes? for more details.
Overall, please don't invent yet another way to store passwords. Instead study How to securely hash passwords? to find out how to do it properly and also for explanations why it should be done this way.