MySQL·MySQL from first query to production

Users and permissions

Create least-privilege accounts and keep credentials out of the codebase.

Beginner 13 min read Lesson 7 of 300 Challenge included
What you will be able to do
  • Create a dedicated user for each app.
  • Grant only SELECT/INSERT/UPDATE/DELETE as needed.
  • Use strong passwords and rotate them.
  • Restrict connections to known hosts.

In plain English

MySQL grants are explicit: a user gets privileges on specific databases or tables. Create a separate user per application and grant only what it needs. Never let the web app connect as root.

grants.sqlSQL
CREATE USER 'edubyte_app'@'%' IDENTIFIED BY 'replace-with-a-secret';
GRANT SELECT, INSERT, UPDATE, DELETE ON edubyte.* TO 'edubyte_app'@'%';
FLUSH PRIVILEGES;
Your turn

Grant read-only access

Easy

Grant SELECT on the edubyte database to a reporting user.

SQL · starter
GRANT
Check your understanding before moving on.
Knowledge checkQuestion 1

Which host pattern allows a user to connect from anywhere?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 7 of 300 · 0% of course