Skip to content

Setup sequel server with docker on mac

Setting up my sequel server
1. Install docker
2. Pull the latest sql image

sudo docker pull microsoft/mssql-server-linux:2017-latest

3. Run the docker command

sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=' -p 1433:1433 --name sql1 -d microsoft/mssql-server-linux:2017-latest

`
* the password must contain 8 characters: capital, lowercase, symbol, number
4. Check if it worked by typing below and checking if the sql server is up (instead of excited)

sudo docker ps -a

If it is not up, try

docker start id container


4. Download Sql Operations studio for mac
5. Connect by entering server: localhost, user: sa, password: , advanced > port : 1433
6. Add a database by right clicking the connection and new Query. It might be that you do not immediately see the database. Reconnect again.See more queries

IF NOT EXISTS (
   SELECT name
   FROM sys.databases
   WHERE name = N'TutorialDB'
)
CREATE DATABASE [TutorialDB]
GO

ALTER DATABASE [TutorialDB] SET QUERY_STORE=ON
GO

7.Add a user with privileges

CREATE ROLE datawriter;
GRANT SELECT,INSERT,DELETE,UPDATE TO datawriter;
GRANT CREATE TABLE TO datawriter;
GRANT ALTER ON SCHEMA::dbo TO datawriter;
CREATE LOGIN datawriter WITH PASSWORD = ;
CREATE USER linklater FOR LOGIN datawriter;
ALTER ROLE datawriter ADD MEMBER linklater;

8. Follow the steps to install sequelize on node

terminal
npm install --save sequelize npm install --save sequelize-cli node_modules/.bin/sequelize init

This will create following folders
config, contains config file, which tells CLI how to connect with database
models, contains all models for your project
migrations, contains all migration files
seeders, contains all seed files
9. Adapt the config with the passwords for production and local environment. In production , add

config.js
"dialectOptions": { "encrypt": true }

10. Create a migration and seed file

Published inTools

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *