0

There is phpmyadmin which give the possibility to secure all databases mysql with an password and username,but my need is to secure my one database,can I lock database mysql with password and username?

1
  • 1
    you can encrypt all your data. You can require credentials to gain granular access to it all. Improve the question Commented Oct 30, 2015 at 16:23

1 Answer 1

0

You can use the grant mysql command to secure a single database or even single ables as described here:

https://dev.mysql.com/doc/refman/5.1/en/grant.html

# 1. Create user
CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';

# 2. Grant right to user
GRANT ALL ON db1.* TO 'jeffrey'@'localhost';
GRANT SELECT ON db2.invoice TO 'jeffrey'@'localhost';
GRANT USAGE ON *.* TO 'jeffrey'@'localhost' WITH MAX_QUERIES_PER_HOUR 90;

Important pitfall: "localhost" may not be the same as 127.0.0.1. The host part of the user also depends on whether you connect to mysql via ip or via socket file.

It is usually good practice to use the minimum required permissions possible. (e.g: Only allow ALTER etc to the admin user)

A list of all perivileges can be found here:

https://dev.mysql.com/doc/refman/5.1/en/grant.html#grant-privileges

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.