tomazsaraiva
3/24/2018 - 11:28 AM

MySQL Commands

// see available databases
SHOW DATABASES;

// create a new database
CREATE DATABASE name;

// delete database
DROP DATABASE name;

// access database
USE name;

// show tables
SHOW tables;

// create table
CREATE TABLE name (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 
name VARCHAR(20),
food VARCHAR(30),
confirmed CHAR(1), 
signup_date DATE);

// see table organization
DESCRIBE name;

// create user for database
GRANT ALL ON databasename.* TO 'username'@'localhost' IDENTIFIED BY 'password';

// update current changes
FLUSH PRIVILEGES;

// exit
exit;
// install
sudo apt-get install mysql-server

// enter as root, change to db user
mysql -u root -p