Reset MariaDB 10.5 root password on Windows 10

This is my frequent problem actually, after doing it so many times in win 7, now it’s time to do it on Windows 10 (finally my OS get upgraded). So let’s get started

  • Stopping mariaDB service by opening run(window + R) , and typing services.msc
  • On list, double click MariaDB. Once the detail window shows, make sure to check the installation path of MariaDB
  • Create a text file containing the password-assignment statement on a single line. Replace the password with the password that you want to use

SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘YourNewPassword!’);
FLUSH PRIVILEGES;

  • Save the file. This example assumes that you name the file C:\mysql-init.txt.
  • Open console window as administrator by accessing start > type cmd > choose run as administrator
  • run mysqld with init configuration (mysql path can be seen on service properties on the previous step)
  • After in run, you may see the process listed in task manager. It alredy execute the query to reset the password, we can stop the service
  • Go to run > services.msc again, and start the service
  • Voila, you can login with the new password on your mariaDB client

References:
MySQL documentation
Stackoverflow
Programmersought blog

Configuring Firewall for port 8080 on Google Cloud and Installing Apache Tomcat 8

In case I forgot this once I want to setup another tomcat, thus I write it down. Setting up tomcat requires java to be ready on the instance, I did the java setup in this post. We know that tomcat is running on port :8080 (default), in order to make it accessible publicly, new firewall rules setup in VPC Network is required.

Setup Firewall Rules

Following the guideline from gcp documentation in this post,

  • Click on Go to the Firewall Page
  • This page will be shown, then click +CREATE FIREWALL RULE
  • Enter the following Fields:
    • Name: name of the Firewall Rule. Name can be anything but it can have only lower case letters, hyphens and numbers
    • Priority: Priority of Rule. Higher the number lower the priority. I keep the default value(1000)
    • Direction of traffic: Ingress. Ingress applies to incoming traffic. Egress applies to outbound traffic.
    • Action on match: allow.
    • Targets: All instance in the network. Because if I plan to have more than one instance I want to make this available for all instance in the network.
    • Source filter: IP Ranges
    • Source IP Ranges: 0.0.0.0/0, means allow any IP, and anyone can send data

Once the firewall setup done, I continue to do the next one,

Installing Tomcat 8

After making sure firewall setup done, and having apache tomcat 8 package downloaded from its official download page, I copy the apache-tomcat-8.5.59.tar.gz to the home directory, then do these steps:

  • Extracting tar.gz
    • $ tar xvf apache-tomcat-8.5.59.tar.gz
  • Copy apache-tomcat-8.5.59 into nginx html and rename it as tomcat8 (if you want to put it in another directory the location can differ.
    • $ sudo mv apache-tomcat-8.5.59 /usr/share/nginx/html/tomcat8
  • Change the owner of tomcat8 directory
    • $ sudo chown -R myuser:myuser tomcat8
  • Edit java security, because in the first try, I can’t get the normal tomcat, and it is because the java security (getting this info from stackoverflow, thanks Bij)
    • go to java security directory, in my case, the directory is located here:
      $ cd /usr/java/jdk1.8.0_271-amd64/jre/lib/security
    • using vi edit java.security file
      $ sudo vi java.security
    • change securerandom.source=file:/dev/random to securerandom.source=file:/dev/./urandom
  • Run tomcat
    • $ cd /usr/share/nginx/html/tomcat8/bin
    • ./startup.sh
  • Check on the browser using PUBLIC_IP:8080

Reference:
1. google cloud computing official documentation
2. bytesofgigabytes web on setting up firewall in google cloud
3. bytesofgigabytes web on installing tomcat
4. stackoverflow answer posted by BiJ

Installing Oracle JDK 8 on Centos 7 (google cloud)

Installing jdk actually is quite simple, I use .rpm installer downloaded from Oracle JDK website.

Once the installer ready in my local, these are the steps:

  1. Upload .rpm installer into cloud using FTP client ( I uploaded the installer into my home directory)
  2. Login using ssh into cloud server
  3. Run the following command to install, verify the installation, and make sure that the installed version is the currently active java, and set the environment for all user respectively
    • sudo yum install <installer name>.rpm
    • java -version
    • sudo alternatives –config java , enter or choose the number of desired java
    • sudo sh -c “echo export JAVA_HOME=/usr/java/jdk1.8.0_161/jre >> /etc/environment”
    • source /etc/environment
[myuser@venus-instance-1 ~]$ sudo yum install jdk-8u271-linux-x64.rpm 
Loaded plugins: fastestmirror
Examining jdk-8u271-linux-x64.rpm: 2000:jdk1.8-1.8.0_271-fcs.x86_64
Marking jdk-8u271-linux-x64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package jdk1.8.x86_64 2000:1.8.0_271-fcs will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package    Arch       Version                   Repository                Size
================================================================================
Installing:
 jdk1.8     x86_64     2000:1.8.0_271-fcs        /jdk-8u271-linux-x64     248 M

Transaction Summary
================================================================================
Install  1 Package

Total size: 248 M
Installed size: 248 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2000:jdk1.8-1.8.0_271-fcs.x86_64                             1/1 
Unpacking JAR files...
	tools.jar...
	plugin.jar...
	javaws.jar...
	deploy.jar...
	rt.jar...
	jsse.jar...
	charsets.jar...
	localedata.jar...
  Verifying  : 2000:jdk1.8-1.8.0_271-fcs.x86_64                             1/1 

Installed:
  jdk1.8.x86_64 2000:1.8.0_271-fcs                                              

Complete!
[myuser@venus-instance-1 ~]$ java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
[myuser@venus-instance-1 ~]$ sudo alternatives --config java

There is 1 program that provides 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/java/jdk1.8.0_271-amd64/bin/java

Enter to keep the current selection[+], or type selection number: 


PS: I took the simplest step to install oracle java 8, other tutorials can be found here, and here.

Setting Up Custom Domain With Google Cloud Compute Engine Instance

After set-up an instance in Google Cloud, I want to map my server to my existing purchased domain. Browsing the steps in GCP user guide feels too complex and I ended up finding this video :

Tutorial by Codedamn

worked like a charm, Thanks a lot Codedamn.

in recap, these are the steps:
1. Make sure you already own a domain, and go to the nameserver setting page( ex: namecheap)

2. Go to GCP console[Networking] > Network Services > Cloud DNS
3. On this page, click CREATE ZONE

4. Fill the details regarding the desired zone (I use the name of my domain), and click CREATE

5. We will get redirected to this page, then click ADD RECORD SET

6. In this page, fill the IPv4 address with the public IP of your VM instances, then click CREATE

7. Done, we got the information of the nameserver ,

8. Click the REGISTRAR SETUP, on the popup copy and paste the list of nameserver(NS) in the nameserver part of the domain setting

9. Done. it may take few min/hour to get it updated, or you may check it on DNS propagation checker page to make sure your domain is refer to the correct address of your server IP.

Preparing VM instance in GCP and enable ssh access using putty

I write down this for self reminder just in case I need a guideline to create another one. As Google Cloud Platform now offering 1 year free tier with 300$ credit, so why not ?

After completing the registration for GCP account, I directly go to GCP console to start exploring. There will be checklist for getting started, such as create your first project, etc.

as the basic one, I tried creating new VM instance for my first server, by accessing it from left menu [compute] > compute engine > VM instances, and fill the following details, finally click create :

  1. Name: [INSTANCE-NAME]
  2. Label: – (optional)
  3. Region: asia-northeast3(seoul)
  4. Machine: e2-small (2vCPU, 2GB memory)
  5. Boot Disk: CentOS 7
  6. Identify and API access: compute engine default service account
  7. Access Scope: Allow default access
  8. Firewall: (check both) Allow HTTP traffic, Allow HTTPS traffic

after clicking create button, I got redirected to this page,

For first access, I tried connect using ssh using native browser, inside the console that I tried setting up the open ssh, and create public key to enable access using puTTy or other ssh client as follows

Installing openssh, starting ssh service, activating the service

sudo yum –y install openssh-server openssh-clients
sudo systemctl start sshd
sudo systemctl enable sshd

After openssh is installed, the next step is generating ssh public/private key for seamless connection using ssh client.

  1. Generating ssh key from native console
  2. Copy the key to local computer
  3. Using puttyGen, convert the key into .ppk
  4. Manage the generated key in GCP metadata

Generating ssh Key

ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME] -C [USERNAME]

Copy the key to local computer

  • click on setting icon on upright, choose download file
  • copy the location of file (full directory address including file name)
  • save the key in local

Generate .ppk

  • Open puttyGen (included in putty installation
  • Locate downloaded private key, by clicking Load
  • enter the passprase (the Passprase when creating the key), click OK
  • Save private key (.ppk)

Once the .ppk is created, registering it to metadata is required by following this guide:

  1. In the Google Cloud Console, go to the Metadata page
  2. Under SSH Keys, click Edit.
  3. Modify the project-wide public SSH keys:
    • To add a public SSH key, click Add item. A text box opens.
    • Copy and paste the contents of your public SSH key file into the text box.Repeat this process for each public SSH key that you want to add.
    • To remove a public SSH key, click the removal button next to it:PuTTYgen public key.Repeat this process for each public SSH key that you want to remove.
  4. When you have finished editing the SSH keys, click Save.

After it’s added into metadata page, I can access ssh using putty, by choosing the authentication using private key authentication (Connection > SSH > Auth > browse .ppk file)

Start Learning C programming reference

Actually this is the second project I joined and requires me to revisit my C programming learning (because skill is not in me yet). I decided to do it from the very beginning as I got new workstation to work with .

I got the setup tutorial from  Dr Paul Denny  and got the Visual Studio Community installed

I tried the steps described in that site, and now I am ready to start my C programming learning journey from these useful sites:

  1. C programming by Alex Allain
  2. Learning C Programming by Programiz
  3. Fresh 2 Fresh | C Programming

last project I tried creating batch processing by combining C and oracle SQL we call it Pro C. This batch program can read the content from fixed formatted text and do bulk insert directly into table in DB

That time I just followed the guidance from the predefined source, without really understanding the purpose of each line of code

Hopefully this time I can learn C programming comprehensively.

oracle installation on ubuntu 16.04

reblogged from tec600.wordpress.com

Site Title

Step 1: Download Oracle Database Express Edition.

Step 2: Instructions before install Oracle

  1. Copy the downloaded file and paste it in home directory.
  2. Unzip using the command:
    unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip 
    
  3. Install required packages using the command:
    sudo apt-get install alien libaio1 unixodbc
    
  4. Enter into the Disk1 folder using command:
    cd Disk1/
    
  5. Convert RPM package format to DEB package format (that is used by Ubuntu) using the command:
    sudo alien --scripts -d oracle-xe-11.2.0-1.0.x86_64.rpm
    
    1. Create the required chkconfig script using the command:
      sudo pico /sbin/chkconfig
      

      The pico text editor is started and the commands are shown at the bottom of the screen. Now copy and paste the following into the file and save:

      #!/bin/bash # Oracle 11gR2 XE installer chkconfig hack for Ubuntu file=/etc/init.d/oracle-xe if [[ ! `tail -n1 $file | grep INIT` ]]; then echo >> $file echo '### BEGIN INIT INFO' >> $file echo '# Provides: OracleXE' >> $file echo '# Required-Start: $remote_fs…

View original post 502 more words

How to access and run PHP with command Line in Windows

You need to add your PHP installation directory to the %PATH% environment variable, or work from the PHP installation directory.

To add it to path (The best approach – Edited for Windows 7):

  • Right-click on a My Computer icon
  • Click Properties
  • Click Advanced system settings from the left nav
  • Click Advanced tab
  • Click Environment Variables button
  • In the System Variables section, select Path (case-insensitive) and click Edit button
  • Add a semi-colon (;) to the end of the string, then add the full file system path of your PHP installation (e.g. C:\Program Files\PHP)
  • Keep clicking OK etc until all dialog boxes have disappeared
  • Close your command prompt and open it again
  • Sorted

Alternatively, you can run cd <PHP installation path> before you try and run you command, or call your script like <FULL file system path of php.exe> <path to script>

Reference:

  1. How to access PHP with the command Line in Windows
  2. Run php file in windows cmd

SMTP gmail on Codeigniter 3

I got this article from stackoverflow as always 😀

Use the following code

And dont froget to unable following two security settings in google.

1) https://www.google.com/settings/security/lesssecureapps << turn it on

2) https://accounts.google.com/b/0/DisplayUnlockCaptcha << Click continue

** Turn off 2 step verification if you have it enabled.

Code :

$config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => 465,
        'smtp_user' => 'dkumara85@gmail.com',    //email id
        'smtp_pass' => 'xxxxxxxxxxx',            // password
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
    );
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");

    $this->email->from('dkumara85@gmail.com','my name');
    $this->email->to("dkumara85@gmail.com"); // email array
    $this->email->subject('email subject');   
    $this->email->message("my mail body");

    $result = $this->email->send();


    show_error($this->email->print_debugger());  // for debugging purpose :: remove this once it works...