postgresql for mac简单操作
2016-09-15 18:58
295 查看
frankslgdeMacBook-Pro:~ frankslg$ pg_ctl -D /usr/local/var/postgres/ -l /usr/local/var/postgres/server.log stop
waiting for server to shut down………….. done
server stopped
在关闭的时候一定要注意,如果有服务正在使用postgresql时,stop会关闭失败
frankslgdeMacBook-Pro:~ frankslg$ pg_ctl -D /usr/local/var/postgres/ -l /usr/local/var/postgres/server.log start
server starting
启动成功之后,需要连接数据库(连接之前先查看有哪些库)
frankslg$ psql -l
然后进入:
frankslgdeMacBook-Pro:~ frankslg$ psql msf psql (9.4.5) Type "help" for help. msf=#
使用命令(方法)查看:
msf=# \? General \copyright show PostgreSQL usage and distribution terms \g [FILE] or ; execute query (and send results to file or |pipe) \gset [PREFIX] execute query and store results in psql variables \h [NAME] help on syntax of SQL commands, * for all commands \q quit psql \watch [SEC] execute query every SEC seconds Query Buffer \e [FILE] [LINE] edit the query buffer (or file) with external editor \ef [FUNCNAME [LINE]] edit function definition with external editor \p show the contents of the query buffer \r reset (clear) the query buffer \s [FILE] display history or save it to file \w FILE write query buffer to file Input/Output \copy ... perform SQL COPY with data stream to the client host \echo [STRING] write string to standard output \i FILE execute commands from file \ir FILE as \i, but relative to location of current script \o [FILE] send all query results to file or |pipe \qecho [STRING] write string to query output stream (see \o) : #此后还有很多命令
使用“\dt”查看当前库中有哪些表
msf=# \dt List of relations Schema | Name | Type | Owner --------+------------------------------------------------+-------+------- public | api_keys | table | msf public | automatic_exploitation_match_results | table | msf public | automatic_exploitation_match_sets | table | msf public | automatic_exploitation_matches | table | msf public | automatic_exploitation_runs | table | msf public | clients | table | msf public | credential_cores_tasks | table | msf public | credential_logins_tasks | table | msf public | creds | table | msf public | events | table | msf
之后就和其它数据库的操作一样了:
msf=# select * from api_keys; id | token | created_at | updated_at ----+-------+------------+------------ (0 rows)
相关文章推荐
- MacOS下对postgresql的简单管理操作
- MacOS下对postgresql的简单管理操作
- PostgreSQL 的一个简单连接和查询操作——示例
- PostgreSQL 数据操作入门,简单对比MySQL
- MacOS下对postgresql的简单管理操作
- postgresql 数据库中数据的导入导出(简单操作+示例)
- postgresql 数据库中数据的导入导出(简单操作+示例)
- postgresql简单操作
- 用C#对ADO.NET数据库完成简单操作
- 对文件的简单读写操作
- asp.net 操作 word 一例(简单的)
- 在C、JAVA、PHP中操作postgreSql数据库
- 操作简单XML文件
- vs2003的一个简单操作
- 一个简单实用的数据库操作框架
- 使用System.DirectoryServices.Protocols实现对AD的简单操作
- 简单的单链表操作
- Linux C实现MySql数据库操作简单实例
- 一个简单实用的数据库操作框架
- 简单的XML操作:XML文件创建