Creating a Database User
We've created the database and put some data in there, now we must create a user
account. This user will have access to this database. We create the user and grant
privileges with the GRANT command:
كود PHP:
mysql> GRANT usage
-> ON example.*
-> TO webuser@localhost;
Query OK, 0 rows affected (0.15 sec)
This creates a new user called webuser. This user can connect only from localhost, and he
has the ability to connect to the example database. Next we have to specify what
operations webuser can perform:
كود PHP:
mysql> GRANT select, insert, delete
-> ON example.*
-> TO webuser@localhost;
Query OK, 0 rows affected (0.00 sec)
This gives webuser the ability to execute SELECT, INSERT, and DELETE queries on every
table of the example database. Our work is done here, exit the MySQL client: