-
-
Save thomasbnt/f02b6d3fea2c9efc76fd0bed52ce5202 to your computer and use it in GitHub Desktop.
Revisions
-
thomasbnt revised this gist
Sep 16, 2022 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,20 @@ CREATE DATABASE database; DROP DATABASE database; ``` ## Manage tables ### Create table ```sql CREATE TABLE table_name; ``` ### Delete table ```sql DROP TABLE table_name; ``` ## Manage users ### Create user -
thomasbnt revised this gist
Jan 27, 2022 . 1 changed file with 23 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -106,4 +106,27 @@ if (!empty($dbname)) { + $cfg['Servers'][$i]['AllowRoot'] = false; } ``` ____ ## Allow remote connection ```bash nano /etc/mysql/my.cnf ``` Or other files who MariaDB/MySQL is registered. ```diff - bind-address = 127.0.0.1 + bind-address = 0.0.0.0 ``` After that, restart the service. ```bash systemctl restart mariadb ``` You can verify if the process listening to the good IP and port with **netstat** : ```bash netstat -ant | grep 3306 ``` -
thomasbnt revised this gist
Jan 16, 2022 . 1 changed file with 16 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -90,4 +90,20 @@ SHOW GRANTS username; ```sql FLUSH PRIVILEGES; ``` _____ ## Disable root login on Phpmyadmin Edit `/etc/phpmyadmin/config.inc.php` ```diff if (!empty($dbname)) { $cfg['Servers'][$i]['auth_type'] = 'cookie'; + $cfg['Servers'][$i]['AllowRoot'] = false; } ``` -
thomasbnt revised this gist
Sep 10, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,8 @@ CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; ### Edit a password for a user ```sql ALTER USER 'username'@'localhost' IDENTIFIED BY 'NEW_USER_PASSWORD'; FLUSH PRIVILEGES; ``` ### Delete user -
thomasbnt revised this gist
Sep 10, 2020 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,6 +19,12 @@ DROP DATABASE database; CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; ``` ### Edit a password for a user ```sql ALTER USER 'user-name'@'localhost' IDENTIFIED BY 'NEW_USER_PASSWORD'; ``` ### Delete user ```sql -
thomasbnt revised this gist
May 8, 2020 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -35,6 +35,10 @@ select host, user, password from mysql.user; ```sql mysqladmin -u root -p password [NewPassword] ``` or ```sql sudo mysqladmin -u root password -p ``` ## Permissions -
thomasbnt revised this gist
Dec 4, 2019 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -24,6 +24,12 @@ CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; ```sql DROP USER ‘username’@‘localhost’; ``` ### Show users ```sql select host, user, password from mysql.user; ``` ### Edit user password ```sql -
thomasbnt revised this gist
Sep 10, 2019 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ DROP USER ‘username’@‘localhost’; ``` ### Edit user password ```sql mysqladmin -u root -p password [NewPassword] ``` @@ -45,32 +45,32 @@ DROP USER ‘username’@‘localhost’; ### Grant permissions ```sql GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost'; ``` ```sql GRANT type_of_permission ON database_name.table_name TO ‘username’@'localhost’; ``` ```sql GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost'; ``` ### Revoke permissions ```sql REVOKE type_of_permission ON database_name.table_name FROM ‘username’@‘localhost’; ``` ### Show permissions ```sql SHOW GRANTS username; ``` ## Flush privileges ```sql FLUSH PRIVILEGES; ``` -
thomasbnt revised this gist
Sep 10, 2019 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -45,32 +45,32 @@ DROP USER ‘username’@‘localhost’; ### Grant permissions ```bash GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost'; ``` ```bash GRANT type_of_permission ON database_name.table_name TO ‘username’@'localhost’; ``` ```bash GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost'; ``` ### Revoke permissions ```bash REVOKE type_of_permission ON database_name.table_name FROM ‘username’@‘localhost’; ``` ### Show permissions ```bash SHOW GRANTS username; ``` ## Flush privileges ```bash FLUSH PRIVILEGES; ``` -
Thomas Bnt revised this gist
May 11, 2019 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -53,6 +53,10 @@ GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost'; GRANT type_of_permission ON database_name.table_name TO ‘username’@'localhost’; ``` ```sql GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost'; ``` ### Revoke permissions ```sql -
Thomas Bnt revised this gist
Jan 30, 2019 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -24,6 +24,11 @@ CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; ```sql DROP USER ‘username’@‘localhost’; ``` ### Edit user password ```bash mysqladmin -u root -p password [NewPassword] ``` ## Permissions -
angristan revised this gist
Feb 12, 2018 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,26 +2,26 @@ ### Create database ```sql CREATE DATABASE database; ``` ### Delete database ```sql DROP DATABASE database; ``` ## Manage users ### Create user ```sql CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; ``` ### Delete user ```sql DROP USER ‘username’@‘localhost’; ``` @@ -40,7 +40,7 @@ DROP USER ‘username’@‘localhost’; ### Grant permissions ```sql GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost'; ``` @@ -50,18 +50,18 @@ GRANT type_of_permission ON database_name.table_name TO ‘username’@'localhos ### Revoke permissions ```sql REVOKE type_of_permission ON database_name.table_name FROM ‘username’@‘localhost’; ``` ### Show permissions ```sql SHOW GRANTS username; ``` ## Flush privileges ```sql FLUSH PRIVILEGES; ``` -
angristan created this gist
Feb 12, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ ## Manage databases ### Create database ``` CREATE DATABASE database; ``` ### Delete database ``` DROP DATABASE database; ``` ## Manage users ### Create user ``` CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; ``` ### Delete user ``` DROP USER ‘username’@‘localhost’; ``` ## Permissions ### Types of permissions * ALL PRIVILEGES * CREATE * DROP * DELETE * INSERT * SELECT * UPDATE * GRANT OPTION ### Grant permissions ``` GRANT ALL PRIVILEGES ON database.* TO 'username'@'localhost'; ``` ```sql GRANT type_of_permission ON database_name.table_name TO ‘username’@'localhost’; ``` ### Revoke permissions ``` REVOKE type_of_permission ON database_name.table_name FROM ‘username’@‘localhost’; ``` ### Show permissions ``` SHOW GRANTS username; ``` ## Flush privileges ``` FLUSH PRIVILEGES; ```