db/mysql

mysql get remote ip address

C/H 2015. 12. 22. 20:30

SELECT USER();
-- root@192.168.26.1
SELECT CURRENT_USER();
-- root@%
select host from information_schema.processlist WHERE ID=connection_id();
-- 192.168.26.1:54755
select INET_ATON(LEFT(HOST, LOCATE(':', HOST)-1)) AS IP from information_schema.processlist WHERE ID=connection_id();
-- 3232242177


반응형