Yes, we can use the same name for the database and database user.
It is a good and quite familiar method. It is commonly in use and does not cause any issues.
One more thing, you need to ensure that they should satisfy with the username and schema naming conversation. You can check more details on it from the below URL:
- http://dev.mysql.com/doc/refman/5.6/en/user-names.html
- http://dev.mysql.com/doc/refman/5.6/en/identifiers.html
Using a different name for database and database users is advisable because it isn't easy to manage if you have multiple databases on your server and you have set the same name to the database users you have set for databases.
If you have set a different name for database and database user, you can quickly identify which one is a database and which one is a database user.
From the example below, you can quickly identify which is a database and which is a database user.
Example:
Database name: accu1cloud_accutest_db
Database username: accu1cloud_accutest_user
It is difficult to identify the exact name of the database and database user. Below is an example of it.
Example:
Database name: accu1cloud_accutest
Database username: accu1cloud_accutest
Also, from the security point of view, you should use a different name for the database and database user. An attacker who knows the database name can easily determine the user name as well if the database name and user name are identical. This could lead to unauthorized access to the database.