Backup Stored Procedures and Routines

We need to specify --routines to take backup of stored procedures with data and tables.

The following command will take backup of entire database including stored procedures. For example, your database name is “mydb”.

mysqldump -u root -p –routines mydb > mydb.sql

To take backup of only Stored Procedures and Triggers (Exclude table and data ) use the following command.

mysqldump –routines –no-create-info –no-data –no-create-db –skip-opt mydb > mydb.sql

Reference:
https://tecadmin.net

PostgreSQL remote connection

This arcticle was writen based PostgreSQL version 10.10 and running on Ubuntu 18.04

Configuring postgresql.conf

Find postgresql.conf

$ find / -name "postgresql.conf"
/usr/lib/tmpfiles.d/postgresql.conf
/etc/postgresql/10/main/postgresql.conf

Open file /etc/postgresql/10/main/postgresql.conf and replace line

listen_addresses = 'localhost'

with

listen_addresses = '*'

Configuring pg_hba.conf

Open file /etc/postgresql/10/main/pg_hba.conf and add following entry at the very end

host    all             all     0.0.0.0/0                    md5
host    all             all     ::/0                         md5

Do not get confused by “md5” option mentioned above. All it means is that a password needs to be provided. If you want client to allow collection without providing any password then change “md5” to “trust” and that will allow connection unconditionally.

Restart postgresql server.

Membuat seluruh elemen dalam Form tidak dapat diakses

Dengan memberikan attribut disabled pada elemen Fieldset

<form id="form1">
    <fieldset disabled>
        <input/>
        <input/>
        <input/>
    </fieldset>
</form>
<br>
<button id="btn_edit">Edit On</button><br>
<button id="btn_lock">Edit Off</button>

Jika menggunakan jQuery :

$("#btn_edit").click(function(){
        $("#form1 :fieldset").prop('disabled',false);
    });

$("#btn_lock").click(function(){
        $("#form1 :fieldset").prop('disabled',true);
    });

 

Upgrade PHP 5.5.x to PHP 5.6 on Ubuntu 14.04

Kebutuhan ini muncul ketika bermaksud menggunakan PHPUnit 5.6 yang mensyaratkan PHP 5.6 padahal saat ini masih menggunakan PHP 5.5.9. Tetap diperhatikan jika Anda memiliki modul-modul tambahan lainnya bisa terjadi akan hilang begitu Anda upgrade biasanya karena link/file-file modul *.so nya tidak ada.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5

Pada saat proses di atas saya lakukan, eeh phalcon.so tidak berada lagi pada tempatnya sebagaimana ketika menggunakan PHP 5.5.9. So be carefull ya teman2.

 

Salam,

 

 

Mencopot MySQL sepenuhnya

Uninstall MySQL dengan apt-get remove terkadang tidak lah cukup, karena tidak menghapus jejak-jejak sepenuhnya.

Berikut perintah-perintah yang lebih ‘gahar’, tapi mohon hati-hati ya, jangan sampai data Anda hilang kalau belum di backup :

sudo -i
service mysql stop
killall -KILL mysql mysqld_safe mysqld
apt-get --yes purge mysql-server mysql-client
apt-get --yes autoremove --purge
apt-get autoclean
deluser --remove-home mysql
delgroup mysql
rm -rf /etc/apparmor.d/abstractions/mysql /etc/apparmor.d/cache/usr.sbin.mysqld /etc/mysql /var/lib/mysql /var/log/mysql* /var/log/upstart/mysql.log* /var/run/mysqld
updatedb
exit

 

MySQL Create Database with utf8mb4 Character Set Syntax

Create database

I frequently create database with utf8mb4 character set:

CREATE DATABASE 'mydb' CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; GRANT ALL ON 'mydb'.* TO 'username'@localhost IDENTIFIED BY 'password'; FLUSH PRIVILEGES;

or

CREATE SCHEMA 'mydb' CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; GRANT ALL ON 'mydb'.* TO 'username'@localhost IDENTIFIED BY 'password'; FLUSH PRIVILEGES;

Create user

Create user and give privilege to it

create user 'username'@localhost identified by 'password'; grant all privileges on *.* to username@localhost; 
or 
GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;

Change user’s password

Replace the password with the password that you want to use.

MySQL 5.7.6 and later:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

MySQL 5.7.5 and earlier:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');

Here is a short list of other common possible permissions that users can enjoy.

  • ALL PRIVILEGES- as we saw previously, this would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
  • CREATE- allows them to create new tables or databases
  • DROP- allows them to them to delete tables or databases
  • DELETE- allows them to delete rows from tables
  • INSERT- allows them to insert rows into tables
  • SELECT- allows them to use the Select command to read through databases
  • UPDATE- allow them to update table rows
  • GRANT OPTION- allows them to grant or remove other users’ privileges

Reference from :

  • http://www.euperia.com/development/mysql/mysql-create-database-with-utf8-character-set-syntax/1064
  • https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

Pemanfaatan checkbox dengan jQuery

Berikut ini adalah beberapa teknik di jQuery untuk bekerja dengan checkbox  :

Pemeriksaan apakah checkbox ditandai (checked)

// Mengembalikan nilai true jika ditandai, dan false selain itu.
$('#checkboxA').is(':checked');

Menandai checkbox

Berdasarkan spesifikasi HTML5, maka atribut haruslah di isi dengan checked=”checked”; bukan sekedar checked atau checked=”true”, dsb.

Read more

MySQL Create Database with UTF8 Character Set Syntax

I always forget the MySQL create database with UTF8 character set syntax, so here it is:

CREATE DATABASE `mydb` CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON `mydb`.* TO `username`@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Alternatively, you can use ‘CREATE SCHEMA’ instead of ‘CREATE DATABASE’:

CREATE SCHEMA `mydb` CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON `mydb`.* TO `username`@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

I hope this helps someone else too!

(*resource : here

Semacam isset() di javascript

Untuk memeriksa apakah sebuah object / variabel terdefinisi / ada atau tidak seperti layaknya fungsi isset() di php, maka kita dapat menggunakan statement typeof cara sebagai berikut :

if (typeof obj.foo != 'undefined') {
  // ..
}

typeof ini akan mengembalikan nilai ‘undefined’ baik object/property tersebut ‘ada’/exist maupun memang bernilai undefined.

Reference : http://stackoverflow.com/questions/2281633/javascript-isset-equivalent

1 2 3 4