1

I'm following this tutorial. I installed the “GDAL Complete” Framework from kyngchaos.com and I tested the installation on Mac. I have GDAL 1.11.2, released 2015/02/10.

When I am trying to run this command:

ogr2ogr -f MySQL MySQL:dbname,user=root,password=password \
      -nln world_borders -nlt MULTIPOLYGON \
      -update -overwrite \
      -lco ENGINE=MyISAM \
      -lco MYSQL_FID=ogr_fid -lco GEOMETRY_NAME=geometry \
      /path/to/TM_WORLD_BORDERS-0.3.shp

With my settings it would be:

ogr2ogr -f MySQL MySQL:mapas,user=xxxx,password=xxxx \
      -nln test -nlt MULTIPOLYGON \
      -update -overwrite \
      -lco ENGINE=MyISAM \
      -lco MYSQL_FID=ogr_fid -lco GEOMETRY_NAME=geometry \
      /Users/Seph/Downloads/TM_WORLD_BORDERS-0.3/TM_WORLD_BORDERS-0.3.shp

I got this error:

Unable to find driver `MySQL'.
The following drivers are available:
-> `ESRI Shapefile'
-> `MapInfo File'
-> `UK .NTF'
-> `SDTS'
-> `TIGER'
-> `S57'
-> `DGN'
-> `VRT'
-> `REC'

I have created the table on my database before running the command.

UPDATE I installed Homebrew I and ran this command:

brew install gdal --with-mysql

Now I have the supported format: -> "MySQL" (read/write)

But now I have this error:

Macbook-pro:~ Seph$ ogr2ogr -f MySQL MySQL:mapas,user=xxxx,password=xxxx\
      -nln test -nlt MULTIPOLYGON \
      -update -overwrite \
      -lco ENGINE=MyISAM \
      -lco MYSQL_FID=ogr_fid -lco GEOMETRY_NAME=geometry \
       /Users/Seph/Downloads/TM_WORLD_BORDERS-0.3/TM_WORLD_BORDERS-0.3.shp
      ERROR 1: MySQL connect failed for: mapas,user=xxxx,password=xxxx
      Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
      ERROR 1: MySQL connect failed for: mapas,user=xxxx,password=xxxx
      Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
      ERROR 1: MySQL connect failed for: mapas,user=xxxx,password=xxxx
      Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
      ERROR 1: MySQL driver doesn't currently support database creation.
      Please create database before using.
      MySQL driver failed to create MySQL:mapas,user=xxxx,password=xxxx

I am using phpMyAdmin from Xammp

  • 1
    does "MySQL" appear when you run: ogrinfo --formats ? – jmcbroom Apr 4 '15 at 5:22
  • Hi, No, It doesn't – Seph1603 Apr 4 '15 at 5:24
2

I know it's been 5 months since this question was posted, but I thought I'd add in my $.02. I, too, had the problem of ogr2ogr not being able to connect.

In my case, it turned out that ogr2ogr expects the mysql.sock file to be in /tmp/. If you're running MAMP, your sock file is actually located in /Applications/MAMP/tmp/mysql/mysql.sock. Creating a symlink fixed the issue for me:

ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/

Also, if you're using Postgres.app AND gdal, be aware that you'll have two versions of ogr2ogr installed. Updating my .bash_profile to look for the version installed via brew install gdal --with-mysql did the trick:

alias ogr2ogr=/usr/local/bin/ogr2ogr

Place that above the PATH directive so it overrides the /Applications/Postgres.app/Contents/Versions/9.3/bin path include that should be in your PATH variable.

I mention this because @jmcboom asked you to run ogrinfo. If, like me, you did that and got no MySQL driver, it is probably because the ogrinfo you're running is looking at the Postgres.app version, not your brew version.

I hope this helps.

Cheers, Steve

0
ogr2ogr **-F** MySQL MySQL:mapas,user=xxxx,password=xxxx \
      -nln test -nlt MULTIPOLYGON \
      -update -overwrite \
      -lco ENGINE=MyISAM \
      -lco MYSQL_FID=ogr_fid -lco GEOMETRY_NAME=geometry \
      /Users/Seph/Downloads/TM_WORLD_BORDERS-0.3/TM_WORLD_BORDERS-0.3.shp

The letter f has to be capitalized.

  • 1
    ..this is not correct. That f is lower-case in 100% of the ogr2ogr instructions I have saved for reuse since I've had my current job. Because you're new and I want to welcome you to the community I'll refrain from down-voting so as not to set you back, but this is unfortunately not correct ..that is, unless this is a unique issue with the Mac build, which I doubt. – elrobis Sep 2 '15 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.