Posts

Showing posts from October, 2018

MySql Command Cheatsheet

First time setup https://linuxize.com/post/install-mysql-on-centos-7/ **************************************************************** Setup initiate Open terminal and edit  /etc/mysql/my.cnf sudo nano / etc / mysql / my . cnf Underneath the  [mysqld]  section.add: lower_case_table_names = 1 Restart mysql sudo / etc / init . d / mysql restart **************************************************************** Remove mysql completely Execute the following command : # rpm -qa | grep mysql It will list all installed mysql packages on your system. Eg:  mysql-libs-5.1.73-3.el6_5.x86_64 now execute the command: # yum remove <name displayed in above step-1> Eg:  yum remove mysql-libs-5.1.73-3.el6_5.x86_64 **************************************************************** > mysql -u root -p > CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; > GRANT ALL ON db1.* TO 'username'@'%'  ...

Express connect to mysql

MySQL Module :  mysql Installation $ npm install mysql Example var mysql = require ( 'mysql' ) var connection = mysql . createConnection ( { host : 'localhost' , user : 'dbuser' , password : 's3kreee7' , database : 'my_db' } ) ; connection . connect ( ) connection . query ( 'SELECT 1 + 1 AS solution' , function ( err , rows , fields ) { if ( err ) throw err console . log ( 'The solution is: ' , rows [ 0 ] . solution ) } ) connection . end ( ) Reference https://expressjs.com/en/guide/database-integration.html https://www.terlici.com/2015/08/13/mysql-node-express.html https://codeburst.io/build-a-rest-api-for-node-mysql-2018-jwt-6957bcfc7ac9 https://github.com/waiyaki/postgres-express-node-tutorial/blob/master/ http://docs.sequelizejs.com/manual/tutorial/models-usage.html#data-retrieval-finders

Express by Node.js

It is a web application framework. Install go to the directory of app > mkdir api > cd api > npm init > npm install express --save > node app.js Or install via Express Generator generator tool,  express-generator , to quickly create an application skeleton. #1  The  express-generator  package installs the  express  command-line tool. Use the following command to do so: npm install express-generator -g cd .. //go to parent path #2 For example, the following creates an Express app named  api . The app will be created in a folder named  api in the current working directory and the view engine will be set to  Pug : express --view=pug api #3 Then install dependencies: $ cd myapp $ npm install #4 Run the app > set DEBUG=myapp:* & npm start In case, need to monitor change install nodemode > npm i -g nodemod > nodemon app.js //instead of calling npm start //Nodemon will watching for changing ...