Saturday, May 21, 2016

Cara Migrasi Aplikasi Monev Sarpras

Kasus : pemilik aplikasi ingin memindahkan hosting aplikasi dari http://www.aplikasi-sarprasristekdikti.com ke http://sarpras.ristekdikti.go.id/monev . Untuk perlu disiapkan :
  1. kumpulan file script, 
  2. data SQL (hasil export), 
  3. lokasi folder di server yang baru (bisa jadi konfigurasi server lama dan baru berbeda), lokasi folder web monev : /var/www/html/monev 
  4. nama database, 
  5. user, password dan privilege
Kebetulan pengembang sudah menyiapkan prosedurnya, yang disimpan dalam file readme.txt. Isi file tersebut adalah sbb :
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - -  - - - - - - - - - - - -
Petunjuk Singkat Instalasi Aplikasi
1. Kebutuhan: Apache Web Server, PHP 6/7, MySQL 4/5
2. Unzip aplikasi-dikti.zip ke public html folder di web server
3. Import my_sql.sql ke MySQL Server
4. Ubah parameter koneksi pada index.html:

/* Primary Variables */

$main_db = 'u473807248_xxxx'; => ubah u473807248_xxxxx ke nama database di step 3
$main_dbhost = 'mysql.idhostixxxx.com'; => ubah mysql.idhostxxxx.com ke nama host mysql di step 3
$main_dbuser = 'u473807248_xxxx'; => ubah u473807248_xxxx ke user database di step 3
$main_dbpwd = 'root@xxxx'; => ubah root@xxxx ke password database di step 3

/* local */

5. Aplikasi siap digunakan.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - —  - - - -

Sesuai mengikuti petunjuk pada  file readme.txt

$main_db = 'u473807248_xxxxx';
$main_dbhost = 'mysql.idhostixxxx.com';
$main_dbuser = 'u473807248_xxxx';
$main_dbpwd = 'root@xxxx';

Login ke aplikasi dengan
u : qwer@xxxx
p : zxcvbn@xxxx

Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'Unknown MySQL server host 'mysql.idhostinger.com' (0)' in /var/www/html/monev/index.php:26 Stack trace: #0 /var/www/html/monev/index.php(26): mysqli->mysqli('mysql.idhosting...', 'u473807248_xxxx', 'root@xxxx', 'u473807248_xxxx...') #1 {main} thrown in /var/www/html/monev/index.php on line 26

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - —  - - - -

Setelah $main_dbhost diubah dengan IP Address :

/* Primary Variables */

$main_db = 'u473807248_xxxx';
$main_dbhost = '202.46.1.xxx';
$main_dbuser = 'u473807248_xxxx';
$main_dbpwd = 'root@xxxx';

/* local */
/*
$main_db = 'aplikasi_dikti';
$main_dbhost = '.';
$main_dbuser = 'docmng';
$main_dbpwd = 'root@xxxx';
*/

Login ke aplikasi dengan
u : u473807248_xxxx
p : root@xxxx

Atau dengan user lain
u : qwer@xxxx
p : zxcvbn@xxxx

Pesan kesalahan :

Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'Can't connect to MySQL server on '202.46.1.xxxx' (111)' in /var/www/html/monev/index.php:26 Stack trace: #0 /var/www/html/monev/index.php(26): mysqli->mysqli('202.46.1.xxxx', 'u473807248_xxxx', 'root@xxxx', 'u473807248_xxxx...') #1 {main} thrown in /var/www/html/monev/index.php on line 26

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - —  - - - -

Coba $main_dbhost menggunakan dengan full qualfied domain name :

$main_db = 'u473807248_xxxx';
$main_dbhost = 'sarpras.ristekdikti.go.id';
$main_dbuser = 'u473807248_xxxx';
$main_dbpwd = 'root@xxxx';

Login ke aplikasi dengan
u : u473807248_xxxx
p : root@xxxx

Atau dengan user lain
u : qwer@xxxx
p : zxcvbn@xxxx

Pesan kesalahan :

Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'Can't connect to MySQL server on 'sarpras.ristekdikti.go.id' (111)' in /var/www/html/monev/index.php:26 Stack trace: #0 /var/www/html/monev/index.php(26): mysqli->mysqli('sarpras.ristekd...', 'u473807248_xxxx', 'root@xxxx', 'u473807248_dikt...') #1 {main} thrown in /var/www/html/monev/index.php on line 26

Coba ikuti petunjuk di http://sekedar-tutorial.blogspot.co.id/2012/11/cara-memindahkan-database-export-dan.html

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - —  - - - -

Login ke MySQL :

iptexxxx@ubuntu:~$ mysql -u xxxx -piptexxxx
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 653
Server version: 5.5.47-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - —  - - - -

Membuat user :
http://www.duniailkom.com/tutorial-belajar-mysql-cara-membuat-dan-menghapus-user-mysql-create-user/

CREATE USER 'nama_user' IDENTIFIED BY 'password' ;

mysql> CREATE USER ilkom_admin2 IDENTIFIED BY 'rahasia';
Query OK, 0 rows affected (0.01 sec)

CREATE USER 'u473807248_xxxx'@'localhost' IDENTIFIED BY 'root@xxxx' ;

mysql> CREATE USER 'u473807248_xxxx' IDENTIFIED BY 'root@xxxx' ;
ERROR 1396 (HY000): Operation CREATE USER failed for 'u473807248_xxxx'@'%'

mysql> CREATE USER 'u473807248_xxxx'@'localhost' IDENTIFIED BY 'root@xxxx' ;
Query OK, 0 rows affected (0.00 sec)

Test login :
mysql -u u473807248_xxxx -proot@xxxx   - - > tidak bisa
mysql -u u473807248_xxxx@localhost -proot@xxxx  - - > OK

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - —  - - - -

Membuat hak akses privilege :
http://www.duniailkom.com/cara-membuat-hak-akses-privileges-user-mysql-grant/

Tutorial :
GRANT hak_akses ON nama_database.nama_tabel TO 'nama_user'@'lokasi_user';
mysql> GRANT SELECT ON universitas.mahasiswa_ilkom TO
'ilkom_admin'@'localhost';
Query OK, 0 rows affected (0.12 sec)

Konsep :
GRANT SELECT ON u473807248_xxxx.* TO 'u473807248_xxxx'@'localhost';

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - —  - - - -
Kesimupulan :

mysql> CREATE USER 'u473807248_xxxx'@'localhost' IDENTIFIED BY 'root@xxxx' ;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT SELECT ON u473807248_xxxx.* TO 'u473807248_xxxx'@'localhost';
Query OK, 0 rows affected (0.00 sec)

Login ke aplikasi sukses dengan user :
u : qwer@xxxx
p : zxcvbn@xxxx
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - —  - - - -

No comments:

Post a Comment