MySQL Security

Creating a New User

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

Creates a new MySQL user.

Granting Permissions

GRANT ALL PRIVILEGES ON my_database.* TO 'newuser'@'localhost';
FLUSH PRIVILEGES;

Grants full privileges on my_database to newuser.

Revoking Permissions

REVOKE ALL PRIVILEGES ON my_database.* FROM 'newuser'@'localhost';

Revokes all privileges from newuser.

Enabling Secure Connections

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';

Ensures secure authentication.