Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MYSQL not allowing JSON data type

Tags:

json

mysql

xampp

I'm trying to add a column of type JSON to one of my tables. I'm using XAMPP with phpmyadmin. The server version is 10.1.31-MariaDB. The innodb version is 5.6.36-83.0

When i try to select the JSON type from the select-box in phpmyadmin, i do not see anything about JSON. Also, running this query results in a "syntax error":

ALTER TABLE my_table
ADD `some_column` json;

I've seen both in the manual, and in various tutorials, that mysql indeed does support JSON type.

Is it a version issue? To be honest, i'm very confused about the whole mysql versioning situation. I see on Wikipedia, that the latest stable release is 8.0.11, whereas mine seems to be something completely different(i dont know which is relevant: the "server" or the "innodb" version) I would assume that XAMPP uses the latest mysql version, but maybe i'm wrong.

Can someone shed some light on the issue? If it is actually a version thing, would it be possible to upgrade, while still using XAMPP?

like image 730
i.brod Avatar asked Apr 28 '18 21:04

i.brod


People also ask

Does MySQL support JSON data type?

MySQL supports a native JSON data type defined by RFC 7159 that enables efficient access to data in JSON (JavaScript Object Notation) documents. The JSON data type provides these advantages over storing JSON-format strings in a string column: Automatic validation of JSON documents stored in JSON columns.

Does MySQL 5.7 support JSON data type?

Unless otherwise indicated, the JSON functions were added in MySQL 5.7. 8. A set of spatial functions for operating on GeoJSON values is also available.

Which MySQL version support JSON?

MySQL version 5.7. 8 introduces a JSON data type that allows you to access data in JSON documents.


1 Answers

It seems that this data type is only available from MariaDB version 10.2.7. You can use LONGTEXT instead, because according to the docs JSON is only an alias for LONGTEXT.

https://mariadb.com/kb/en/library/json-data-type/

like image 123
Ebby Avatar answered Sep 21 '22 22:09

Ebby