WordPress / Web Development Tutorials
(Best WordPress Tutorials)

Silva Web Designs - Blog

How to grant MySQL database table privileges

When creating a database-driven windows application it is very important to create a database user with specific privileges.

The reason for granting specific privileges to the user account is to assure that if your application falls a victim of disaster/hack, the data is safe and secure.

When you have created a database, create a user that will have access to it. Once you have that created, specify the grants which enable that user to Select, Insert, Update, Delete and etc specific to the database table.

In our example we are going to assume we have a database called “db_Sales” which has 3 tables:

1). Address
2). Orders
3). Deliveries

We have database user as “User” and password as “Password”

GRANT ALL PRIVILEGES ON db_Sales.Address TO 'User'@'%';
GRANT SELECT,INSERT, DELETE ON db_Sales.Orders TO 'User'@'%';
GRANT SELECT,INSERT ON db_Sales.Deliveries TO 'User'@'%';

The code above means that the user will be able to do everything from selecting to deleting a record in the Address table. However, the user will only be allowed to Select, Insert and Delete records on Orders and on Deliveries table, the user can only Select and Insert records. All other commands will be denied keeping the database safe from getting misused.


Nathan da Silva - Profile

Posted by: Nathan da Silva

Nathan is the Founder of Silva Web Designs. He is passionate about web development, website design and basically anything digital-related. His main expertise is with WordPress and various other CMS frameworks. If you need responsive design, SEO, speed optimisation or anything else in the world of digital, you can contact Silva Web Designs here; [email protected]

It’s good to share

Join the discussion

Related Posts

Wordpress / 20th January 2019

Create a new WordPress admin user in the database

Read More

MySQL / 27th July 2016

How to Add Admin User to WordPress with MySQL

Read More