Last active
August 23, 2019 10:40
-
-
Save aryehbeitz/a7bcfd06fe69fbd443396ec91c243735 to your computer and use it in GitHub Desktop.
mysql stuff
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
mysql -u root -p | |
FLUSH PRIVILEGES; | |
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password'; | |
GRANT SELECT ON *.* TO 'username'@'localhost'; | |
mysql -u username -p | |
CREATE DATABASE dbname; | |
USE dbname; | |
mysql -u username -p < example.sql | |
DROP DATABASE dbname; | |
SELECT user FROM mysql.user GROUP BY user; | |
DELETE FROM mysql.user WHERE user = 'username'; | |
How to reset root MySQL password | |
sudo service mysql stop | |
sudo mkdir -p /var/run/mysqld | |
sudo chown mysql:mysql /var/run/mysqld | |
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking & | |
jobs | |
mysql -u root | |
FLUSH PRIVILEGES; | |
USE mysql; | |
UPDATE user SET authentication_string=PASSWORD("password") WHERE User='root'; | |
UPDATE user SET plugin="mysql_native_password" WHERE User='root'; | |
sudo pkill mysqld | |
sudo service mysql start | |
#restore database: | |
gunzip < db.sql.gz | mysql -u username -p db_name | |
#create user | |
CREATE USER 'peter'@'%' IDENTIFIED BY '1234'; | |
#delete user | |
DROP USER 'peter'@'%'; | |
#grant privileges | |
GRANT ALL PRIVILEGES ON *.* TO 'peter'@'%'; | |
#revoke privileges | |
REVOKE ALL PRIVILEGES ON *.* FROM 'peter'@'%'; | |
FLUSH PRIVILEGES; | |
DROP USER IF EXISTS 'user'@'localhost'; | |
CREATE USER 'user'@'localhost' IDENTIFIED BY 'pass'; | |
GRANT ALL PRIVILEGES ON database_name.* TO 'user'@'localhost'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment