full backup & restore mysql (linux)

14 Apr

1. backup
mysqldump -u root -p –all-databases > alldb_backup.sql

2. copy to traget
ftp 172.20.33.142
Name (172.20.33.142:root): oracle
Password:
ftp> put alldb_backup.sql
ftp> bye

3. remote
ssh root@172.20.33.142
root@172.20.33.142’s password:

4. restore
cd /home/oracle
mysql -u root -p  < alldb_backup.sql
Enter password:

RASPBERRY PI : Setting apache & PHP

14 Oct

=================================================================================
RASPBERRY PI : Setting apache & PHP
=================================================================================
pi@raspberrypi ~ $ sudo apt-get install apache2 apache2-doc apache2-utils

sudo apt-get update
sudo apt-get upgrade

apt-get install php5-mysql
apt-get install mysql-server mysql-client
sudo nano /var/www/phpinfo.php

<?php
phpinfo();
?>

RASPBERRY PI : Backup dan Restore Table mysql

14 Oct

=================================================================================
RASPBERRY PI : Backup dan Restore Table mysql
=================================================================================
A1. backup database
pi@raspberrypi ~ $ mysqldump -u root -p akses_masuk > backup_db_akses_masuk.sql
Enter password:

A2. backup table
pi@raspberrypi ~ $ pi@raspberrypi ~ $ mysqldump -u root -p akses_masuk user  > table_user2.sql
Enter password:

pi@raspberrypi ~ $ mysqldump -u root -p akses_masuk user_log  > table_user_log2.sql
Enter password:

B. RESTORE
pi@raspberrypi ~ $ mysql -u root -p
Enter password: xxxxxxxx
mysql> CREATE DATABASE akses_masuk;
mysql> exit
pi@raspberrypi ~ $ mysql -u root -p akses_masuk < table_user.sql
Enter password:
pi@raspberrypi ~ $ mysql -u root -p akses_masuk < table_user_log.sql
Enter password:

RASPBERRY PI : Seeting server mysql agar bisa diakses dari LAN

14 Oct

=================================================================================
RASPBERRY PI : Seeting server mysql agar bisa diakses dari LAN
=================================================================================
sisi server mysql
===========================
pi@raspberrypi ~ $ mysql -u root -p
Enter password: xxxxxxxx
mysql> CREATE DATABASE akses_masuk;
mysql> USE akses_masuk;
mysql> CREATE USER ‘root’@’172.20.35.11’ IDENTIFIED BY ‘xxxxxxxx’;
mysql> CREATE USER ‘root’@’172.20.35.12’ IDENTIFIED BY ‘xxxxxxxx’;
mysql> CREATE USER ‘root’@’172.20.35.13’ IDENTIFIED BY ‘xxxxxxxx’;
mysql> CREATE USER ‘root’@’172.20.35.14’ IDENTIFIED BY ‘xxxxxxxx’;
mysql> CREATE USER ‘root’@’172.20.35.15’ IDENTIFIED BY ‘xxxxxxxx’;
mysql> CREATE USER ‘root’@’172.20.33.42’ IDENTIFIED BY ‘xxxxxxxx’;

mysql> GRANT ALL PRIVILEGES ON akses_masuk.* TO ‘root’@’172.20.35.11’;
mysql> GRANT ALL PRIVILEGES ON akses_masuk.* TO ‘root’@’172.20.35.12’;
mysql> GRANT ALL PRIVILEGES ON akses_masuk.* TO ‘root’@’172.20.35.13’;
mysql> GRANT ALL PRIVILEGES ON akses_masuk.* TO ‘root’@’172.20.35.14’;
mysql> GRANT ALL PRIVILEGES ON akses_masuk.* TO ‘root’@’172.20.35.15’;
mysql> GRANT ALL PRIVILEGES ON akses_masuk.* TO ‘root’@’172.20.33.42’;
mysql> FLUSH PRIVILEGES;
mysql> exit

pi@raspberrypi ~ $ sudo nano /etc/mysql/my.cnf
bind-address            = 172.20.35.12
pi@raspberrypi ~ $ sudo /etc/init.d/mysql restart

===========================
sisi client mysql
===========================
[root@ubsweb ~]# mysql -u root -h 172.20.35.12 -p

Mengatasi MYSQL ERROR 1045 (28000)

14 Oct

Mengatasi MYSQL ERROR 1045 (28000)

#ERROR 1045 (28000): Access denied for user ‘root’@’
#ERROR 1045 (28000)
#Access denied for user ‘root’@’

===========================================================
KASUS :
A. SERVER MYSQL : 172.20.35.11
B. CLIENT MYSQL : 172.20.33.42
===========================================================
DARI CLIENT MYSQL : 172.20.33.42
===========================================================
[root@ubsweb ~]# mysql -u root -h 172.20.35.11 -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@’172.20.33.42’ (using password: YES)

===========================================================
DARI SERVER MYSQL : 172.20.35.11
===========================================================
pi@turnstile1 ~ $ mysql -u root -p
Enter password:
mysql> USE akses_masuk;
mysql> CREATE USER ‘root’@’172.20.33.42’ IDENTIFIED BY ‘xxxxxxxxxxxxx’;
ERROR 1396 (HY000): Operation CREATE USER failed for ‘root’@’172.20.33.42’

mysql>  SELECT user, host FROM mysql.user;
+——————+————–+
| user             | host         |
+——————+————–+
| root             | 127.0.0.1    |
| root             | 172.20.35.11 |
| root             | 172.20.35.12 |
| root             | 172.20.35.13 |
| root             | 172.20.35.14 |
| root             | 172.20.35.15 |
| root             | 172.20.35.31 |
| root             | 172.20.75.17 |
| root             | ::1          |
| debian-sys-maint | localhost    |
| pi               | localhost    |
| root             | localhost    |
+——————+————–+

mysql> drop user root@172.20.33.42;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE USER ‘root’@’172.20.33.42’ IDENTIFIED BY ‘xxxxxxxxxxxxx’;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON akses_masuk.* TO ‘root’@’172.20.33.42’;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT user, host FROM mysql.user;
+——————+————–+
| user             | host         |
+——————+————–+
| root             | 127.0.0.1    |
| root             | 172.20.33.42 |
| root             | 172.20.35.11 |
| root             | 172.20.35.12 |
| root             | 172.20.35.13 |
| root             | 172.20.35.14 |
| root             | 172.20.35.15 |
| root             | 172.20.35.31 |
| root             | 172.20.75.17 |
| root             | ::1          |
| debian-sys-maint | localhost    |
| pi               | localhost    |
| root             | localhost    |
+——————+————–+
17 rows in set (0.01 sec)

mysql> quit
Bye

===========================================================
DARI CLIENT MYSQL : 172.20.33.42
===========================================================
[root@ubsweb ~]# mysql -u root -h 172.20.35.11 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 99
Server version: 5.5.41-0+wheezy1 (Debian)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use akses_masuk;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> quit
Bye

Create Local YUM repository on CentOS 7 / RHEL 7 using DVD

13 Feb

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Create Local YUM repository on CentOS 7 / RHEL 7 using DVD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# df -h
/dev/sdb1       3.9G  3.9G     0 100% /run/media/root/CentOS 7 x86_64
# ln -s /run/media/root/CentOS\ 7\ x86_64/ /mnt/cdrom
# ls -la /mnt/cdrom/
# vi /etc/yum.repos.d/local.repo
[LocalRepo]
name=Local Repository
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

# yum clean all
# yum install vsftpd

change hostname CentOS 7

13 Feb

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
change hostname CentOS 7
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# hostname
localhost.localdomain
# nmtui-hostname
# systemctl restart systemd-hostnamed
# hostname
linux.localdomain