Skip to content

Instantly share code, notes, and snippets.

@arjus
Last active April 27, 2018 10:45
Show Gist options
  • Save arjus/7e4d2b1b8ce2a68bb513a0f2c38db1b7 to your computer and use it in GitHub Desktop.
Save arjus/7e4d2b1b8ce2a68bb513a0f2c38db1b7 to your computer and use it in GitHub Desktop.
Create a new Mysql database and User with secure password
# access mysql. i'll use root as default user.
mysql -u root -p{your passwrord - default is root or admin or read mysql message after installation}
#create a new database
create database database_name;
#create a new user
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
#access permits to the new database
GRANT ALL PRIVILEGES ON database_name. * TO 'newuser'@'localhost';
#flush all privileges
FLUSH PRIVILEGES;
#check users
select user,host from mysql.user;
#show permissions
show grants for 'user'@'host';
#revoke permissions
REVOKE [type of permission] ON [database name].[table name] FROM ‘[username]’@‘localhost’;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment