MySQL/MariaDB Reference

From The Linux Source
Revision as of 13:17, 19 May 2017 by Support (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  • List Databases*
 mysql> show databases;
  • List Tables*
 mysql> show tables;
  • Change Passwords*
 # mysqladmin -u root password 'new-password'

Note: the mysqladmin command should be run from a shell script, so as to not have this critical password exposed in the command history - make sure to delete the shell script after running

  • Delete Database*
 mysql> drop database test;
  • Creating a new DB and assigning permissions*

Command line/scripted

 # mysqladmin -p create wikidb
 # echo "grant index, create, select, insert, update, delete, alter, lock tables on wikidb.* to 'wikiuser'@'localhost' identified by 'password';" | mysql -p

Note: the echo command should be run from a shell script, so as to not have a critical password exposed in the command history - make sure to delete the shell script after running

mySQL command line - note: this is added to the mysql command history (not a good idea to leave the password exposed):

 # mysql -p
 mysql> create database wikidb;
 mysql> grant index, create, select, insert, update, delete, alter, lock tables on wikidb.* to 'wikiuser'@'localhost' identified by 'password';
  • Delete From Table*
  • Table Structure*
  • View Data (Some Query Examples)*