I have a vector layer displaying geometry from a mysql view.

This works fine for several days/weeks until suddenly it fails to refresh and my layer reverts to a non-geometry table, losing all symbols, labels etc.

Closing the project without saving and reverting does not revert back to the previous working state. I am able to add a new vector layer to the same view that displays correctly but without my custom symbols.

Is there any way to fix my layer (re-establish the geometry field) without having to start from scratch?

Edit: QGIS 2.18.16, MySQL 5.6.14

1 Answer 1


Not a fix for the underlying problem, but try to add the layer back as a new vector layer then:

  • Layer|Copy style, then
  • Layer|Paste style

That should make the newly-added layer match the old style; you can then remove the old layer.

Longer term solution: save the style as the default in the database from the Properties dialog.

  • Thanks for the response. When I try paste from the old layer I get 'Cannot past style: Cannot apply style to layer with a different geometry type' error. I've remade my styles and saved them as you suggested so hopefully can recover faster next time.
    – Maximus
    Mar 19, 2018 at 6:40
  • Looks like there was an old bug (MySQL 5.0.x) that had geometry problems in views - can't see anything recent though.
    – Simbamangu
    Mar 19, 2018 at 7:12
  • Update: the default style works for adding the data as a new layer. My vector layer is from a view - could the layer become broken due to the view being altered?
    – Maximus
    Mar 26, 2018 at 1:57
  • I haven't used MySQL in a very long time so can't try to reproduce the issue. The bug I link to above matches your symptoms (views / lost geometry), so you might want to update your version (though it references a much older, supposedly fixed one) anyway or search for similar bugs?
    – Simbamangu
    Mar 26, 2018 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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