Skip to content

Instantly share code, notes, and snippets.

@prasidhda
Last active October 20, 2021 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prasidhda/e34f6fc5b7d1b47b2e0f0d772a81e8b8 to your computer and use it in GitHub Desktop.
Save prasidhda/e34f6fc5b7d1b47b2e0f0d772a81e8b8 to your computer and use it in GitHub Desktop.
To install SQL in linux debian versions
In latest version, mySQL uses auth_socket, so to login you've to know about the auto generated user credentials. or if you download binary version, while installation process, you can choose lagacy password.
To install SQL in linux debian versions
sudo apt install mysql-server
to know about the password
sudo cat /etc/mysql/debian.cnf
Now login
mysql -u debian-sys-maint -p
use the password from debian.cnf
How to see available user records:
USE mysql
SELECT User, Host, plugin FROM mysql.user;
Now you can create a new user. Use the below commands:
use mysql;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'username'@'localhost';
flush privileges;
To list the grants for the particular mysql user
SHOW GRANTS FOR 'username'@'localhost';
How to revoke all the grants for the particular mysql user
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'username'@'localhost';
To delete/remove particular user from user account list
DROP USER 'username'@'localhost';
For more commands:
$ man 1 mysql
Please don't reset the password for root, instead create a new user and grant rights. This is the best practice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment