MySQL commands

Some (often used) commands for MySQL DB….
Logging into DB :
# mysql -u root -p
How to show colons in table named “users” :
mysql> show columns from users;
How to show only some fields from table “users” :
mysql> select username,password from users;
Deleting accounts (take care! this is possible ONLY after all account privileges ahve been deleted) :
mysql> drop user user1;
Which grants exist for user “user1” :
mysql> show grants for ‘user1’@’localhost’;
How to remove all privileges from “user1” :
mysql> revoke all privileges, grant option from ‘user1’@’localhost’;
Adding new account to previously selected DB :
mysql> grant usage on *.* to ‘user1’@’localhost’ identified by ‘my-password’;
Show all grants for user1 :
mysql> show grants for ‘korisnik1’@’localhost’;

This entry was posted in Linux and tagged , . Bookmark the permalink.

Comments are closed.