Users and privileges

Create MySQL application accounts

Create separate local accounts for application queries and schema migrations without giving either one global access.

8 minute lesson

~~~

MySQL accounts include both a name and a connection host. Create two local accounts:

CREATE USER 'notes_app'@'localhost'
  IDENTIFIED BY 'replace-with-a-generated-secret';

CREATE USER 'notes_migrator'@'localhost'
  IDENTIFIED BY 'replace-with-another-generated-secret';

Use generated secrets in real deployments. Do not copy the example text into production.

Creating an account does not grant access to notes_app. We will add only the privileges each responsibility needs.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →