Last active
October 20, 2021 12:05
-
-
Save prasidhda/e34f6fc5b7d1b47b2e0f0d772a81e8b8 to your computer and use it in GitHub Desktop.
To install SQL in linux debian versions
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
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