Skip to content

Instantly share code, notes, and snippets.

@dbonates
Last active December 16, 2015 04:09
Show Gist options
  • Save dbonates/5375018 to your computer and use it in GitHub Desktop.
Save dbonates/5375018 to your computer and use it in GitHub Desktop.
mySQL - General and usefull commands
# change root password (pass '' to remove password)
mysqladmin -u root -p'old_password' password 'new_password'
# Log with user bonates just using database database_name:
mysql -u bonates -p simple_cms_development
# create an user and give him all access to a table
GRANT ALL PRIVILEGES ON table_name.* to 'user_name'@'localhost' identified by 'user_password';
# general and obvious:
CREATE DATABASE database_name;
SHOW DATABASES;
SHOW TABLES;
SHOW FIELDS FROM table_name;
SELECT * FROM table_name;
USE table_name;
DROP TABLE table_name;
SHOW GRANTS FOR 'user_name'@'localhost';
ALTER TABLE table_name CHANGE fieldname new_fieldname varchar(40);
SELECT * FROM users WHERE username LIKE 'admin%';
UPDATE users SET auth_token_expires_at= '2013-04-10 07:12:46' WHERE id=2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment