This project is using MySql as the persistent layer for storing employee info. The following user, database and table need to exist before running the backend service:
- Create user
gocrud
CREATE USER gocrud@'localhost' IDENTIFIED BY 'password';
- Grant privilage:
GRANT ALL PRIVILEGES ON *. * TO gocrud@'localhost';
- Grant privilage:
- Create database
gocrud_db
CREATE DATABASE gocrud_db;
- Create
employee
tableCREATE TABLE `employee` (`id` int(6) unsigned NOT NULL AUTO_INCREMENT,`name` varchar(30) NOT NULL,`city` varchar(30) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
export DB_USER="<database username>"
export DB_NAME="<database name>"
export DB_PASSWORD="<database password>"
go build main.go
go run main.go