Last active
August 16, 2023 06:49
-
-
Save akolinski/d0a1668fd009b66ecd003f86583a8c5d to your computer and use it in GitHub Desktop.
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
show databases; | |
SELECT User,Host FROM mysql.user; | |
SHOW GRANTS FOR 'root'@'localhost'; | |
GRANT ALL PRIVILEGES ON * . * TO 'root'@'localhost'; | |
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root'; | |
FLUSH PRIVILEGES; | |
-------- | |
// If you get the error "Access denied for user 'root'@'localhost'" when running the ./setupdb.sh script | |
// @docs = https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost | |
sudo mysql -u root -p | |
USE mysql; | |
UPDATE user SET plugin='mysql_native_password' WHERE User='root'; | |
FLUSH PRIVILEGES; | |
exit; | |
-------- | |
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; | |
GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost'; | |
FLUSH PRIVILEGES; | |
// Get list of mysql user accounts and host | |
SELECT User,Host FROM mysql.user; | |
// Delete a user | |
DROP USER 'root'@'localhost'; | |
SHOW GRANTS FOR 'username'@'localhost'; | |
GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost'; | |
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='username'; | |
FLUSH PRIVILEGES; | |
// ######## Resources ######## | |
// https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql | |
// https://strongpasswordgenerator.com/ | |
// http://stackoverflow.com/questions/1135245/how-to-get-a-list-of-mysql-user-accounts | |
// http://stackoverflow.com/questions/19237475/cannot-grant-privileges-to-mysql-database | |
// https://stackoverflow.com/questions/17975120/access-denied-for-user-rootlocalhost-using-password-yes-no-privileges | |
mysql -uroot -p // Then type in 'root' as password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment