1. buat direktori
$ mkdir -p /baks/mysql
2. buat file mysql_backups.sh trus copy-paste kode ini
3. trus buat crontab nya..
$crontab -e
10 3 * * * /root/mysql_backups.sh > /baks/status.log
source: seanbehan.com
[root@localhost ~]# useradd pebriana
[root@localhost ~]# passwd pebriana
Changing password for user pebriana.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]#
[root@localhost ~]# su - pebriana
[pebriana@localhost ~]$
[pebriana@localhost ~] tar -xzvf postgresql-8.4.1.tar.gz
[pebriana@localhost ~]$ cd postgresql-8.4.1
[pebriana@localhost postgresql-8.4.1]$ ls
aclocal.m4 configure contrib doc HISTORY Makefile src
config configure.in COPYRIGHT GNUmakefile.in INSTALL README
[pebriana@localhost postgresql-8.4.1]$ ./configure –prefix=/home/pebriana/pgsql
[pebriana@localhost postgresql-8.4.1]$ make
make[1]: Leaving directory `/home/pebriana/postgresql-8.4.1/config'
All of PostgreSQL successfully made. Ready to install.
[pebriana@localhost ~]$ su
password:
[root@localhost ~]# make install
make[1]: Leaving directory `/home/pebriana/postgresql-8.4.1/config'
PostgreSQL installation complete.
[root@localhost ~]# su pebriana
password:
[pebriana@localhost ~]$ mkdir /home/pebriana/pgsqldata
[pebriana@localhost ~]$ chown pebriana.pebriana /home/pebriana/pgsqldata
[pebriana@localhost ~]$ /home/pebriana/pgsql/bin/initdb -D /home/pebriana/pgsqldata/
The files belonging to this database system will be owned by user "pebriana".
This user must also own the server process.
fixing permissions on existing directory /home/pebriana/pgsqldata ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /home/pebriana/pgsqldata/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
Success. You can now start the database server using:
/home/pebriana/pgsql/bin/postgres -D /home/pebriana/pgsqldata
or
/home/pebriana/pgsql/bin/pg_ctl -D /home/pebriana/pgsqldata -l logfile start
[pebriana@localhost ~]$ /home/pebriana/pgsql/bin/pg_ctl -D /home/pebriana/pgsqldata -l logfile start
server starting
[pebriana@localhost ~]$ /home/pebriana/pgsql/bin/pg_ctl -D /home/pebriana/pgsqldata -l logfile start
waiting for server to shut down.... done
server stopped
[pebriana@localhost ~]$ psql template1
Welcome to psql 8.1.11 (server 8.4.1), the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
WARNING: You are connected to a server with major version 8.4,
but your psql client is major version 8.1. Some backslash commands,
such as \d, might not work properly.
template1=#
template1=# alter user pebriana with password '12345';
ALTER ROLE
template1=# \q
[pebriana@localhost ~]$ cd pgsqldata
[pebriana@localhost pgsqldata]$ vim pg_hba.conf
[pebriana@localhost pgsqldata]$ vim postgresql.conf
[pebriana@localhost pgsqldata]$ /home/pebriana/pgsql/bin/pg_ctl -D /home/pebriana/pgsqldata -l logfile restart
[pebriana@localhost pgsqldata]$ createuser apri -P -U pebriana
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
CREATE ROLE
[pebriana@localhost pgsqldata]$ createdb tes -U apri
password:
CREATE DATABASE
[pebriana@localhost pgsqldata]$ psql tes -U apri
Welcome to psql 8.1.11 (server 8.4.1), the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
WARNING: You are connected to a server with major version 8.4,
but your psql client is major version 8.1. Some backslash commands,
such as \d, might not work properly.
tes=>
[pebriana@localhost pgsqldata]$ dropdb tes -U apri