Mysql Mariadb Set Update Password

Nov 30, 2019 1 min.

Using mysqladmin CLI If you installed the db with empty password then set the password sudo mysqladmin password "<<new-password>>" -- OR mysqladmin --user=root password "<<new-password>>" Change the existing password mysqladmin --user=root --password=<<old-password>> password "<<new-password>>" Using SET PASSWORD SET PASSWORD FOR '<<user>>'@'<<hostname|ip>>' = PASSWORD('<<new-password>>'); Using SQL Update Change the password by the SQL update to the table mysql.users (Execute this query as root) USE mysql; UPDATE user SET password=PASSWORD('<<new-password>>') WHERE User='<<user>>' AND Host = '<<hostname|ip>>'; FLUSH PRIVILEGES; Using ALTER ALTER USER '<<user>>'@'<<hostname|ip>>' IDENTIFIED BY '<<new-password>>>'; FLUSH PRIVILEGES; OR

Remove Files From Git Repo as in Gitignore

May 15, 2019 1 min.

After you committed/pushed files to GIT repository, if you decide to ignore some files/directories using .gitignore then they won't be automatically removed from git repository. Following command can be used for removing those ignored files from repo. TL;DR git rm -r --cached . git add . git commit -m ".gitignore fix" git push Detailed Explanation To remove the the ignored files/dirs from repo, use GIT remove command as follows. git rm -r --cached .

NodeJS - Unit Test DynamoDB

May 10, 2019 2 min.

Introduction This page explains how to mock dynamodb client using Sinon and Proxyqurie Required dependencies Install the following dependencies npm install --save-dev sinon npm install --save-dev proxyquire Sample Project Setup a sample project # Create a sample project directory mkdir myproject cd myproject # Initalize npm npm init -y # Install project dependencies npm install aws-sdk # Install Unit test framework globally (if you have not already installed) npm install -g mocha # Install Test dependencies npm install --save-dev sinon npm install --save-dev proxyquire create a index.

How to Enable Disable Startup Services in Ubuntu

Mar 15, 2019 1 min.

Enable / Disable startup service Apache2 # Disable a startup service sudo systemctl disable apache2 # Or sudo update-rc.d apache2 disable # Enable a startup service sudo systemctl enable apache2 # Or sudo update-rc.d apache2 enable MySQL # Disable a startup service sudo systemctl disable mysql # Enable a startup service sudo systemctl enable mysql Remove / Add # Delete sudo update-rc.d apache2 remove #Or sudo update-rc.d -f apache2 remove # To add it back sudo update-rc.

How to Clear Cloudfront Cache Using Aws Cli

Jan 9, 2019 1 min.

aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*' Replace $DISTRIBUTION_ID with the cloudfront distributions ID Referece: https://docs.aws.amazon.com/cli/latest/reference/cloudfront/create-invalidation.html

Extract Data From Json String

Jan 8, 2019 1 min.

myjson='{"somekey":"someval"}' v=`echo $myjson | jq '.somekey'` echo $v output: "someval" # Get the value wihout quotes v=`echo $myjson | jq -r '.somekey'` echo $v output: someval

Steps to create never expiring Facebook access token

Jul 4, 2018 1 min.

Open Graph API Explorer https://developers.facebook.com/tools/explorer Select the application in the “Application” drop-down menu (Note: Not the “My Apps” menu) Click “Get Token” > “Get User Access Token” In the pop-up, under the “Extended Permissions” tab, check “manage_pages” and “publish_pages” Click “Get Access Token” In the popup, grant access from a Facebook account that has access to manage the target pages (This popup will flash and disappear if permissions are already granted) Copy the token that appears in the “Access Token” field (which is your short-lived access token) Invoke the following URL which gives long lived token (expires in 2 months): https://graph.

Enable grub boot menu from window 10

Dec 29, 2017 1 min.

Execute the following command from Windows 10 in command prompt (run as administrator) bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi Execution Logs for reference: Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. C:\WINDOWS\system32>bcdedit Windows Boot Manager -------------------- identifier {bootmgr} device partition=\Device\HarddiskVolume1 path \EFI\Microsoft\Boot\bootmgfw.efi description Windows Boot Manager locale en-US inherit {globalsettings} default {current} resumeobject {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} displayorder {current} toolsdisplayorder {memdiag} timeout 30 Windows Boot Loader ------------------- identifier {current} device partition=C: path \WINDOWS\system32\winload.

MySQL MariaDB Export and Import

Dec 26, 2017 2 min.

Export the database Use the following command to export the database mysqldump --user=<<db-user>> --password=<<db-password \  --host=<<db-host>> --port=3306 \ --single-transaction --compress --routines \ --result-file=dump.sql \ --databases <<db-name>>; Note: Include –single-transaction –compress to export and import quickly. Check documentation for the use --rountines will include procedures/functions in the dump (triggers included by default) --result-file will be the output file (instead of this param, output redirection like mysqldump [options] > dump.sql can be used, however it may have charset issues in OS like windows if you have any blob columns then include –hex-blob Import the database Use the following command to import the database

MySQL MariaDB Create User

Dec 26, 2017 1 min.

Create a user similar to root To create user with all the privileges similar to root. CREATE USER 'superuser'@'%' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'superuser'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES; Create user for Backup A separate user with minimal privileges for taking database dump. CREATE USER 'backup'@'localhost' IDENTIFIED BY 'mypassword'; GRANT SELECT, SHOW VIEW, RELOAD, REPLICATION CLIENT, EVENT, TRIGGER, LOCK TABLES ON *.* TO 'backup'@'localhost'; Note: