postgresql for mac简单操作

    xiaoxiao2022-08-06  9


    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) : #此后还有很多命令


    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)