Mac OS X Open Source Databases Cheat Sheet - FTP Directory ...

boreddizzyΔιαχείριση Δεδομένων

16 Δεκ 2012 (πριν από 4 χρόνια και 7 μήνες)

241 εμφανίσεις

Mac OS X Open Source Databases Cheat Sheet
http://www.google.pl/search?q=cache:lbI9b1JKMpoC:conferences....
1
of
6
12/5/02
3:52
PM
To
jest
wersja
html
pliku
http://conferences.oreillynet.com/presentations/macosx02/bjepson-databases.doc
.
G

o

o

g

l

e

automatycznie
generuje
wersj
ę

html
dokumentu
podczas
przegl
ą
dania
strony.
Aby
po
ł
ą
czy
ć

si
ę

z
t
ą

stron
ą

lub
j
ą

zatwierdzi
ć
,
u
ż
yj
nast
ę
puj
ą
cego
adresu
url:
http://www.google.com/search?q=cache:lbI9b1JKMpoC:conferences.oreillynet.com/presentations/macosx02/bjepson-databases.doc+PostgreSQL+startup+Mac+OS+X&hl=pl&ie=UTF-8&inlang=pl
Google nie jest w
ż
aden
sposób
zwi
ą
zany z autorami tej strony i nie jest odpowiedzialny za jej tre
ś
ć
.
Znalezione s
ł
owa zosta
ł
y pod
ś
wietlone:
postgresql
startup
mac
os
x

Mac
OS
X
Open Source Databases
O
x
Reilly
Mac
OS
X
Conference
Brian
Jepson
bjepson@oreilly.com
PostgreSQL
Source
Code
www.
postgresql
.org
Binary
Distribution
www.entropy.ch/software/MacOSx/
postgresql
JDBC
Driver
jdbc.
postgresql
.org
Transcript of a Successful Source Installation
Step
1.
Get
the
source
code
(go
to
www.
postgresql
.org
to
locate
the
latest
source
distribution,
instead
of
using
the
w
curl
x

command
shown
below):

%
cd
src/
%
curl
-O
http://www.ca.
postgresql
.org/ftpsite/dev/
postgresql
-snapshot.tar.gz
%
Total
%
Received
%
Xferd
Average
Speed
Time
Curr.

Dload
Upload
Total
Current
Left
Speed
100
10.8M
100
10.8M
0
0
155k
0
0:01:11
0:01:11
0:00:00
97014

Step
2.
Extract
and
configure
the
source
code:

%
tar
xfz
postgresql
-snapshot.tar.gz
%
cd
postgresql
-snapshot
%
./configure
--without-readline
checking
build
system
type...
powerpc-apple-darwin6.0
checking
host
system
type...
powerpc-apple-darwin6.0
checking
which
template
to
use...
darwin

...
output
trimmed
for
brevity
...

config.status:
linking
./src/backend/port/dynloader/darwin.h
to
src/include/dynloader.h
config.status:
linking
./src/include/port/darwin.h
to
src/include/pg_config_os.h
config.status:
linking
./src/makefiles/Makefile.darwin
to
src/Makefile.port

Step
3.
Compile
and
install
PostgreSQL
:

%
gnumake
gnumake
-C
doc
all
gzip
-d
-c
man.tar.gz
|
/sw/bin/tar
xf
-
for
file
in
man1/*.1;
do
\
...
output
trimmed
for
brevity
...
rm
-f
libplpgsql.so
ln
-s
libplpgsql.so.1.0
libplpgsql.so
All
of
PostgreSQL

successfully
made.
Ready
to
install.
%
sudo
gnumake
install
Password:
********
gnumake
-C
doc
install
mkdir
/usr/local/pgsql
mkdir
/usr/local/pgsql/doc

...
output
trimmed
for
brevity
...

Thank
you
for
choosing
PostgreSQL
,
the
most
advanced
open
source
database
engine.
Mac OS X Open Source Databases Cheat Sheet
http://www.google.pl/search?q=cache:lbI9b1JKMpoC:conferences....
2
of
6
12/5/02
3:52
PM
Step
4.
Create
the
postgres
user:

%
sudo
nicl
/
-create
/users/postgres
uid
701
%
sudo
nicl
/
-create
/users/postgres
gid
20
#
staff
%
sudo
nicl
/
-create
/users/postgres
shell
/bin/tcsh
%
sudo
nicl
/
-create
/users/postgres
home
/usr/local/pgsql
%
sudo
nicl
/
-create
/users/postgres
realname
"
PostgreSQL

User"
%
sudo
nicl
/
-create
/users/postgres
passwd
\*
%
nidump
passwd
.
|
grep
postgres
postgres:*:701:20::0:0:
PostgreSQL

User:/usr/local/pgsql:/bin/tcsh

Step
5.
Set
up
the
data
directory:

%
sudo
mkdir
/usr/local/pgsql/data
%
sudo
chown
postgres
/usr/local/pgsql/data

Step
6.
Initialize
PostgreSQL
:

%
sudo
su
-
postgres
postgres%
/usr/local/pgsql/bin/initdb
-D
/usr/local/pgsql/data
The
files
belonging
to
this
database
system
will
be
owned
by
user
"postgres".
This
user
must
also
own
the
server
process.

...
output
trimmed
for
brevity
...

Success.
You
can
now
start
the
database
server
using:


/usr/local/pgsql/bin/postmaster
-D
/usr/local/pgsql/data
or

/usr/local/pgsql/bin/pg_ctl
-D
/usr/local/pgsql/data
-l
logfile
start

Step
7.
Start
the
PostgreSQL

Server
and
create
a
test
database:

postgres%
(/usr/local/pgsql/bin/postmaster
-D
/usr/local/pgsql/data
\
?
>
/tmp/pglog)
>&
/tmp/pgerr
&
[1]
14306
postgres%
/usr/local/pgsql/bin/createdb
test
CREATE
DATABASE
postgres%
/usr/local/pgsql/bin/psql
test
Welcome
to
psql
7.3devel,
the
PostgreSQL

interactive
terminal.

Step
8.
Issue
some
SQL
statements:

test=#
create
table
my_test_table
(name
char(32));
CREATE
TABLE
test=#
insert
into
my_test_table
values
('Brian');
INSERT
16978
1
test=#
select
*
from
my_test_table;

name
----------------------------------
Brian
(1
row)

test=#
drop
table
my_test_table;
DROP
TABLE
PostgreSQL
Startup Scripts
Filename:
/Library/StartupItems/
PostgreSQL
/
PostgreSQL
Mode:
0755
Note:
Add
a
line
containing
y
PGSQL=-YES-
z

to
/etc/hostconfig.

#!/bin/sh

#
Source
common
setup,
including
hostconfig.
#
.
/etc/rc.common

Mac OS X Open Source Databases Cheat Sheet
http://www.google.pl/search?q=cache:lbI9b1JKMpoC:conferences....
3
of
6
12/5/02
3:52
PM
PG=/usr/local/pgsql
STARTCMD="$PG/bin/pg_ctl
start
-D
'$PG/data'
-s
-l
$PG/data/serverlog"
STOPCMD="$PG/bin/pg_ctl
stop
-D
'$PG/data'
-s
-m
fast"

StartService()
{

#
Don't
start
unless
PostgreSQL

is
enabled
in
/etc/hostconfig

if
[
"${PGSQL:=-NO-}"
=
"-YES-"
];
then

ConsoleMessage
"Starting
PostgreSQL
"

su
-
postgres
-c
"$STARTCMD"

fi
}

StopService()
{

ConsoleMessage
"Stopping
PostgreSQL
"

su
-
postgres
-c
"$STOPCMD"
}

RestartService()
{

#
Don't
restart
unless
PostgreSQL

is
enabled
in
/etc/hostconfig

if
[
"${PGSQL:=-NO-}"
=
"-YES-"
];
then

ConsoleMessage
"Restarting
PostgreSQL
"

StopService

StartService

else

StopService

fi
}

RunService
"$1"

Filename:
/Library/StartupItems/
PostgreSQL
/StartupParameters.plist
Mode:
0644
<?xml
version="1.0"
encoding="UTF-8"?>
<!DOCTYPE
plist

SYSTEM
"file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist
version="0.9">
<dict>

<key>Description</key>

<string>
PostgreSQL
</string>

<key>Provides</key>

<array>

<string>
PostgreSQL
</string>

</array>

<key>Requires</key>

<array>

<string>Network</string>

</array>

<key>OrderPreference</key>

<string>Late</string>
</dict>
</plist>

Mac OS X Open Source Databases Cheat Sheet
http://www.google.pl/search?q=cache:lbI9b1JKMpoC:conferences....
4
of
6
12/5/02
3:52
PM
MySQL
Source
Code
www.mysql.com
Binary
Distribution
www.entropy.ch/software/MacOSx/mysql
JDBC
Driver
www.mysql.com/downloads/api-jdbc.html
Transcript of a Successful Source Installation
Step
1.
Get
the
source
code
(go
to
www.mysql.com
to
locate
the
latest
source
distribution,
instead
of
using
the
w
curl
x

command
shown
below):

%
cd
src/
%
curl
-O
http://mysql.he.net/Downloads/MySQL-4.0/mysql-4.0.3-beta.tar.gz

%
Total
%
Received
%
Xferd
Average
Speed
Time
Curr.

Dload
Upload
Total
Current
Left
Speed
100
342
0
342
0
0
1655
0
--:--:--
0:00:00
--:--:--
0

Step
2.
Extract
and
configure
the
source
code:

%
tar
xfz
mysql-4.0.3-beta.tar.gz
%
cd
mysql-4.0.3-beta
%
setenv
LDFLAGS
-lncurses
%
./configure
--prefix=/usr/local/mysql
checking
build
system
type...
powerpc-apple-darwin6.0
checking
host
system
type...
powerpc-apple-darwin6.0
checking
target
system
type...
powerpc-apple-darwin6.0

...
output
trimmed
for
brevity
...

Thank
you
for
choosing
MySQL!

Step
3.
Compile
and
install
MySQL:

%
make
cd
libmysql;
make
link_sources
set
-
x
;
\

ss=`echo
strmov.lo
strxmov.lo
strxnmov.lo
strnmov.lo

...
output
trimmed
for
brevity
...

binary-configure.sh
>
binary-configure-t
/bin/mv
binary-configure-t
binary-configure
make[2]:
Nothing
to
be
done
for
`all-am'.
%
sudo
make
install
Password:
Making
install
in
include
make[2]:
Nothing
to
be
done
for
`install-exec-am'.
/bin/sh
../mkinstalldirs
/usr/local/mysql/include/mysql

...
output
trimmed
for
brevity
...

/usr/bin/install
-c
-m
644
./binary-configure
/usr/local/mysql/share/mysql/binary-configure
make[2]:
Nothing
to
be
done
for
`install-exec-am'.
make[2]:
Nothing
to
be
done
for
`install-data-am'.
%
sudo
./scripts/mysql_install_db
Preparing
db
table
Preparing
host
table
Preparing
user
table

...
output
trimmed
for
brevity
...
http://www.mysql.com
Support
MySQL
by
buying
support/licenses
at
https://order.mysql.com

Step
4.
Set
permissions
on
the
MySQL
directories:

%
sudo
chown
-R
root
/usr/local/mysql
%
sudo
chown
-R
mysql
/usr/local/mysql/var
%
sudo
chgrp
-R
mysql
/usr/local/mysql

Mac OS X Open Source Databases Cheat Sheet
http://www.google.pl/search?q=cache:lbI9b1JKMpoC:conferences....
5
of
6
12/5/02
3:52
PM
Step
5.
Install
the
sample
configuration
file,
start
the
server,
and
create
a
sample
database:

%
sudo
cp
support-files/my-medium.cnf
/etc/my.cnf
%
sudo
/usr/local/mysql/bin/mysqld_safe
--user=mysql
&
[1]
10837
Starting
mysqld
daemon
with
databases
from
/usr/local/mysql/var
%
sudo
/usr/local/mysql/bin/mysqladmin
create
demo

Step
6.
Issue
some
SQL
statements:

%
sudo
/usr/local/mysql/bin/mysqladmin
create
demo
%
/usr/local/mysql/bin/mysql
-u
root
demo
Welcome
to
the
MySQL
monitor.
Commands
end
with
;
or
\g.
Your
MySQL
connection
id
is
3
to
server
version:
4.0.3-beta-log

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

mysql>
create
table
my_test_table
(name
char(32));
Query
OK,
0
rows
affected
(0.01
sec)

mysql>
insert
into
my_test_table
values
('Brian');
Query
OK,
1
row
affected
(0.00
sec)

mysql>
select
*
from
my_test_table;
+-------+
|
name
|
+-------+
|
Brian
|
+-------+
1
row
in
set
(0.00
sec)

mysql>
drop
table
my_test_table;
Query
OK,
0
rows
affected
(0.00
sec)

MySQL
Startup Scripts
Filename:
/Library/StartupItems/MySQL/MySQL
Mode:
0755
Note:
Add
a
line
containing
y
MYSQL=-YES-
z

to
/etc/hostconfig.
#!/bin/sh

#
Source
common
setup,
including
hostconfig.
#
.
/etc/rc.common

StartService()
{

#
Don't
start
unless
MySQL
is
enabled
in
/etc/hostconfig

if
[
"${MYSQL:=-NO-}"
=
"-YES-"
];
then

ConsoleMessage
"Starting
MySQL"

/usr/local/mysql/bin/safe_mysqld
--user=mysql
&

fi
}

StopService()
{

ConsoleMessage
"Stopping
MySQL"

/usr/local/mysql/bin/mysqladmin
shutdown
}

RestartService()
{

#
Don't
restart
unless
MySQL
is
enabled
in
/etc/hostconfig
Mac OS X Open Source Databases Cheat Sheet
http://www.google.pl/search?q=cache:lbI9b1JKMpoC:conferences....
6
of
6
12/5/02
3:52
PM

if
[
"${MYSQL:=-NO-}"
=
"-YES-"
];
then

ConsoleMessage
"Restarting
MySQL"

StopService

StartService

else

StopService

fi
}

RunService
"$1"

Filename:
/Library/StartupItems/MySQL/StartupParameters.plist
Mode:
0644
<?xml
version="1.0"
encoding="UTF-8"?>
<!DOCTYPE
plist

SYSTEM
"file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist
version="0.9">
<dict>

<key>Description</key>

<string>MySQL</string>

<key>Provides</key>

<array>

<string>MySQL</string>

</array>

<key>Requires</key>

<array>

<string>Network</string>

</array>

<key>OrderPreference</key>

<string>Late</string>
</dict>
</plist>