Skip to content

ip2location-com/docker-ip2location-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 

Repository files navigation

docker-ip2location-mysql

This is a pre-configured, ready-to-run MySQL server with IP2Location Geolocation database setup scripts. It simplifies the development team to install and set up the IP2Location geolocation database in MySQL server. The setup script supports the commercial database packages and free LITE package. Please register for a free or commercial account before running this image, as it requires a download token during the setup process.

Usage

  1. Create a dedicated network so that your application containers can communicate with the IP2Location container by name.

    docker network create ip2location-network
  2. Run this image as daemon using the download token and product code from IP2Location LITE or IP2Location and attaching it to the network created above.

    docker run --name ip2location \
    --network ip2location-network \
    -d \
    -e TOKEN={DOWNLOAD_TOKEN} \
    -e CODE={DOWNLOAD_CODE} \
    -e MYSQL_PASSWORD={MYSQL_PASSWORD} \
    ip2location/mysql

    ENV Variables

    TOKEN - Download token obtained from IP2Location.

    CODE - Database code. Codes available as below:

    • Free Database - DB1-LITE, DB3-LITE, DB5-LITE, DB9-LITE, DB11-LITE

    • Commercial Database - DB1, DB2, DB3, DB4, DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, DB13, DB14, DB15, DB16, DB17, DB18, DB19, DB20, DB21, DB22, DB23, DB24, DB25, DB26

    IP_TYPE - (Optional) Download IPv4, IPv6 or both database. Script will download both database by default.

    • IPV4 - Download IPv4 database only.
    • IPV6 - Download IPv6 database only.
    • BOTH - Download IPv4 & IPv6 database.

    MYSQL_PASSWORD - (Optional) Password for MySQL admin. A random password will be generated by default.

  3. The installation may take seconds to minutes depending on your database sizes, downloading speed and hardware specs. You may check the installation status by viewing the container logs. Run the below command to check the container log:

    docker logs -f ip2location

    You should see the line of > Setup completed if you have successfully complete the installation. Also, you should notice the generated password for the MySQL admin login as below:

     mysql -u admin -p{MYSQL_PASSWORD} ip2location_database
    

    Please write down the password somewhere else, as you will need it later for MySQL connection.

Connect from an Application

Run your application container on the same network. The IP2Location container is reachable by its container name (ip2location) as the hostname:

docker run --network ip2location-network -t -i {YOUR_APPLICATION}

Query for IP Information

Below is an example of how to lookup for information of 8.8.8.8 IP address.

mysql -h ip2location -u admin -p{MYSQL_PASSWORD} ip2location_database -e 'SELECT * FROM `ip2location_database` WHERE INET6_ATON("8.8.8.8") <= ip_to LIMIT 1'

Update IP2Location Database

To update your IP2Location database to latest version, please run the following command:

docker exec -it ip2location ./update.sh

Articles and Tutorials

You can visit the below link for more information about this docker image: IP2Location Articles and Tutorials

About

This is a pre-configured, ready-to-run MySQL server with IP2Location Geolocation database setup scripts. It simplifies the development team to install and set up the geolocation database in MySQL server.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors