Skip to content

Instantly share code, notes, and snippets.

@hfogelberg
Created June 20, 2017 08:56
Show Gist options
  • Save hfogelberg/7e8004de531674bb27605e2d52e96486 to your computer and use it in GitHub Desktop.
Save hfogelberg/7e8004de531674bb27605e2d52e96486 to your computer and use it in GitHub Desktop.
Start mysql
$ mysql.server start
Login as root
$ mysql -u root -p
Show databases
mysql> SHOW DATABASES
Create database
mysql> CREATE DATABASE my_test_db;
Switch database
mysql> USE my_test_db;
List tables in database
mysql> SHOW tables;
Create table
mysql> CREATE TABLE Posts(
-> id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
-> title VARCHAR(50) NOT NULL,
-> text TEXT NOT NULL,
-> created DATE NOT NULL);
Show schema defenition
mysql> DESCRIBE Posts;
Insert
mysql> INSERT INTO `Posts`(`title`, `text`, `created`) VALUES("Hello World", "Lorem Ipsum", NOW());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment