简体   繁体   中英

PostgreSQL: store IP address of a connection in a table

I'd like to have a column in a Postgres table which will store the remote IP address of the user connecting to the database. I'm thinking of data type "inet" with some sort of default constraint. Any ideas?

Thanks.

你的函数是inet_client_addr()

查询以使所有ip客户端连接到数据库

SELECT client_addr FROM pg_stat_activity

Can you be a little more specific? Do you mean to record the IP of every user that connects with the psql command line, or do you have a website built with a Postgres database on the backend? If you're logging from a website, then the inet datatype should work great.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM