---
title: "GeoServer+MySQL安装及配置过程"
author: "simen_net"
date: "2010-03-05T23:41:47Z"
tags: []
categories: ["行业应用"]
slug: "geoserver-mysql"
draft: false
lastmod: "2010-03-05T23:41:47Z"
id: 609092
url: "https://simen-net.iteye.com/blog/609092"
---

GeoServer的安装配置请参考 [http://simen-net.iteye.com/blog/609078](/blog/609078)

 

由于大部分WEBGIS不仅仅只是一个地图的显示，还需要一些业务处理，会有用到数据库地方，所以我想把地图放到数据库中，这样性能、安全等方面都有了较大的改进，尤其是修改地图时可以直接对数据库进行操作。这里测试了以MySQL为后台的安装配置

 

1、下载安装MySQL5

 

2、转换地图到数据库

下载http://code.google.com/p/qogr2ogr/，这个是一个很好的开源小工具，其实是ogr2ogr的gui程序，大家要多鼓励鼓励阿！！！这个小工具可以直接支持mysql的输入导入，很是方面，大家参考下面的图片进行操作就可以了。这里的数据库名称为map  
![](http://dl.iteye.com/upload/attachment/212812/2bb5d7de-1d69-3e20-b1e3-e421294711fb.jpg)

 

3、下载安装GeoServer的MySQL插件

MySQL的插件(http://downloads.sourceforge.net/geoserver /geoserver-2.0.1-mysql-plugin.zip)，解压geoserver-2.0.1-mysql-plugin.zip，将gt-jdbc-mysql-2.6.1.jar和mysql-connector-java-5.1.5.jar拷贝到webapps/geoserver/WEB-INF/lib之后请重启Tomcat

 

4、新建MySQL的Store

![](http://dl.iteye.com/upload/attachment/212816/cd2123a6-a4ac-38d3-8270-49f441c82287.png)

 

这里选择MySQL作为Store，填写的内容应该没有太多要所的，大家参考下图

![](http://dl.iteye.com/upload/attachment/212818/a25ea064-45b4-366e-affe-740853b49b91.png)

保存后出现以下界面，这里显示发现了数据库中的三个表，但有用的只有bount\_line，所以我们只publish他

![](http://dl.iteye.com/upload/attachment/212820/cad59cfa-68df-367b-a654-8a569e944430.png)

以下需要注意！！！这里有两个选单［Data］和［Publishing］，Data部分参考[http://simen-net.iteye.com/blog/609078](/blog/609078) 中shp配置的方法，这里特诉的还需要设置以下［Publishing］部分  
![](http://dl.iteye.com/upload/attachment/212822/6e503c0a-d7f8-318e-bd30-f75286a9fe44.png)

［Publishing］中要设置一下Default Style为line，为什么呢？因为我用的是bount\_line地图，他其实是一个line类型，在[http://simen-net.iteye.com/blog/609078](/blog/609078) 中不需要设置［Publishing］感觉是因为GeoServer通过shp文件识别出了他的类型，但是转换成数据库之后识别不出了，这里如果不设置成line的类型话，发布也能成功，但是显示的地图就全是点了。  
![](http://dl.iteye.com/upload/attachment/212826/bb44a78e-b3da-34a5-8fdf-9dea7e9db017.png)

 

剩下的和[http://simen-net.iteye.com/blog/609078](/blog/609078) 一样了