Last active
April 27, 2018 10:45
-
-
Save arjus/7e4d2b1b8ce2a68bb513a0f2c38db1b7 to your computer and use it in GitHub Desktop.
Create a new Mysql database and User with secure password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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