Last active
December 25, 2021 05:59
-
-
Save SeyedMostafaAhmadi/db3ad54f5fbf77941edd3be43da9ddaf to your computer and use it in GitHub Desktop.
Useful commands in mysql
This file contains 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
### create user name with specific password | |
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; | |
### create database | |
CREATE DADTABASE database-namee; | |
### grant all privileges to user for all databases | |
GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost'; | |
### grant all privileges to user for specific database | |
GRANT ALL PRIVILEGES ON database-name . * TO 'username'@'localhost'; | |
### grant all privileges to user for specific database and tabe | |
GRANT ALL PRIVILEGES ON databases-name . tabale-name TO 'username'@'localhost'; | |
### grant specific permissions to user name for databases and tables | |
GRANT type_of_permission ON database_name.table_name TO 'username'@'localhost'; | |
### revoke specific permissions to user name for databases and tables | |
REVOKE type_of_permission ON database_name.table_name FROM 'username'@'localhost'; | |
### export all databases from mysql | |
mysqldump -u username -p --all-databases > alldb.sql | |
### export from specific database from mysql | |
mysqldump -u username -p database-name > database-name.sql | |
### import database to mysql | |
mysql -u username -p database-name < datanase-name-file.sql | |
### imoprt specifi table name to mysql database | |
mysql -u username -p -D database-name < table-name.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment