1 |
<!DOCTYPE html> |
2 |
<html> |
3 |
<head> |
4 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
5 |
<title>MidnightBSD PostgreSQL Documentation</title> |
6 |
<link rel="shortcut icon" href="/favicon.ico"> |
7 |
<link rel="stylesheet" type="text/css" href="../css/essence.css"> |
8 |
</head> |
9 |
<body> |
10 |
<div id="globe"> |
11 |
<div id="header"><h1 title="MidnightBSD Home"><a href="../" title="MidnightBSD Home">MidnightBSD: The BSD For Everyone</a></h1></div> |
12 |
<!--#include virtual="/menu.html"--> |
13 |
<div class="clear"></div> |
14 |
<div id="text"> |
15 |
<h2><img src="../images/oxygen/doc32.png" alt="" /> PostgreSQL Documentation</h2> |
16 |
<div id="toc"> |
17 |
<h3>Contents</h3> |
18 |
<ul> |
19 |
<li><a href="#s1b">Introduction</a></li> |
20 |
<li><a href="#s1c">Install</a></li> |
21 |
<li><a href="#s1d">Examples</a></li> |
22 |
<li><a href="index.html"><strong>Documentation</strong></a></li> |
23 |
<li><a href="../wiki/"><strong>MidnightBSD Wiki (more)</strong></a></li> |
24 |
</ul> |
25 |
</div> |
26 |
<h3 id="s1a">PostgreSQL</h3> |
27 |
<h4 id="s1b">Introduction</h4> |
28 |
<p>PostgreSQL is a full featured, modern database available in mports.</p> |
29 |
|
30 |
<p>Recently, the MidnightBSD project began migrating our package cluster software, Magus, |
31 |
over to PostgreSQL. This is a starter guide on basic functions under PostgreSQL. |
32 |
</p> |
33 |
|
34 |
|
35 |
<h4 id="s1c">Install</h4> |
36 |
|
37 |
<p>Install the PostgreSQL server mport via package or mports. To install by package, |
38 |
you may use a command such as <code>mport install postgresql91-server</code>. |
39 |
</p> |
40 |
<p>For mports, <code>cd /usr/mports/databases/postgresql91-server; make install clean</code> |
41 |
</p> |
42 |
|
43 |
<p>There are several versions of PostgreSQL available in mports and via package. You may wish |
44 |
to check for the latest.</p> |
45 |
|
46 |
<p>A new user called pgsql will be created as part of the installation. You may become |
47 |
root and then run <code>su - pgsql</code> to get access to this user. The command |
48 |
line utilities will be available on the path. |
49 |
</p> |
50 |
|
51 |
<h4 id="s1d">Examples</h4> |
52 |
<p>These examples assume you're using the pgsql user account. May of these commands |
53 |
can be done through direct connects to the server as well.</p> |
54 |
|
55 |
<h5>Create Database</h5> |
56 |
<p>Via console: <code>createdb databasename</code> |
57 |
<p>Via psql prompt</p> |
58 |
<code>create database dbname ENCODING 'UTF-8' OWNER username;</code> |
59 |
|
60 |
<h5>Granting Permissions</h5> |
61 |
<code> grant all on database dbname to username;</code> |
62 |
<h5>List Tables</h5> |
63 |
<p>psql then \d</p> |
64 |
|
65 |
<h5>List Databases</h5> |
66 |
<p>psql then \l</p> |
67 |
|
68 |
<h5>Describe Table</h5> |
69 |
<p>psql then \d+ table |
70 |
|
71 |
<h5>Create User</h5> |
72 |
<code>$ psql |
73 |
> create user username password 'password'; |
74 |
</code> |
75 |
|
76 |
|
77 |
<div id="disqus_thread"></div> |
78 |
<script type="text/javascript"> |
79 |
var disqus_shortname = 'midnightbsd'; |
80 |
|
81 |
(function() { |
82 |
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; |
83 |
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; |
84 |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); |
85 |
})(); |
86 |
</script> |
87 |
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> |
88 |
<a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a> |
89 |
</div> |
90 |
<!--#include virtual="/footer.html"--> |
91 |
</body> |
92 |
</html> |