Home > Article > Backend Development > Create a database and independent database account with phpMyadmin_PHP tutorial
Generally speaking, there is more than one website on a server, and more than one MySQL (the best combination with PHP) database. In order to prevent security risks, we generally set up an independent database access account for each database, and this account only has permission to access the database.
下载地址: | PHPMyadmin |
Let us demonstrate it in detail:
1. First we need to log in to phpMyAdmin.
2. Create a database, as shown below. In the right window of phpMyAdmin, fill in the database name and click Create.
Figure 1
For example, here we create a database named: cncmstest
If the creation is successful, there will be The following prompts:
Figure 2
3. Click the home button in the upper left corner to return to php (as now Mainstream development language) MyAdmin main interface:
Figure 3
4. Click " on the right side of the main interface Permissions" to create a database account.
Figure 4
5. In the permissions page, we click "Add New User"
Figure 5
6. In this page, we fill in the database user name to be created and the access scope of the user. and password.
Figure 6
As shown above, we filled in the user name: cncmsuser. This database user only allows this user. For computer access, select local for host; we use automatically generated passwords. Click "Generate" below to generate a random password, and then click "Copy" to automatically fill in the password box.
Don’t select any of the boxes below, just scroll to the bottom of the page and click Execute to create a new user.
If the database user is successfully created, the following page will be returned:
Figure 7
7. The most important In the first step, set the database access permissions of the user
You can set the permissions directly on the page returned after the database user is successfully added. Here we choose to specify permissions by database:
Figure 8
As shown above, select what we just did in the database list The created cncmstest will automatically enter the permission setting page of the database.
Figure 9
In the permission settings in the above figure, we combine "data" and "structure" Select all column permissions and leave none of the management permissions selected. Just click Execute.
At this point, we have completed all settings, created a database: cncmstest, and created the database user cncmsuser, specifically specifying that the user only has access rights to cncmstest. In this way, we achieve the purpose we talked about at the beginning: specifying independent user access rights for each database.