short-link icon indicating copy to clipboard operation
short-link copied to clipboard

安装提示 check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json

Open qianjigit opened this issue 6 years ago • 17 comments

您好,请问:

Executing CREATE ls_user: Success Executing CREATE ls_link: Success Executing CREATE ls_log: string(223) "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci' at line 13" Failed Executing CREATE ls_query_log: Success

是不支持 MariaDb 吗?

环境: centos7 php 7.1 nginx 1.8.1 MariaDb 10.1.26

qianjigit avatar Dec 26 '18 03:12 qianjigit

你好:

MariaDB 是从 Mysql 衍生而来,理论上是支持的。

我查了一下相关文档,应该是你所使用的版本尚不支持 json 类型,该特性在10.2 被加入,参考 MariaDB: JSON datatype supported as of 10.2 https://ma.ttias.be/mariadb-json-datatype-supported-10-2/

升级MariaDB版本应该就能解决该问题。

qianji [email protected] 于2018å¹´12月26日周三 上午11:18写道:

您好,请问:

Executing CREATE ls_user: Success Executing CREATE ls_link: Success Executing CREATE ls_log: string(223) "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci' at line 13" Failed Executing CREATE ls_query_log: Success

是不支持 MariaDb 吗?

环境: centos7 php 7.1 nginx 1.8.1 MariaDb 10.1.26

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/newnius/short-link/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/AKu2pGJEb-mZAt9jXoy7f1c6mLMpcMp3ks5u8uqAgaJpZM4ZhUoC .

newnius avatar Dec 26 '18 03:12 newnius

好的,感谢,我先做个尝试后再反馈

qianjigit avatar Dec 26 '18 03:12 qianjigit

你好: MariaDB 是从 Mysql 衍生而来,理论上是支持的。 我查了一下相关文档,应该是你所使用的版本尚不支持 json 类型,该特性在10.2 被加入,参考 MariaDB: JSON datatype supported as of 10.2 https://ma.ttias.be/mariadb-json-datatype-supported-10-2/ 升级MariaDB版本应该就能解决该问题。 qianji [email protected] 于2018å¹´12月26日周三 上午11:18写道: … 您好,请问: Executing CREATE ls_user: Success Executing CREATE ls_link: Success Executing CREATE ls_log: string(223) "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci' at line 13" Failed Executing CREATE ls_query_log: Success 是不支持 MariaDb 吗? 环境: centos7 php 7.1 nginx 1.8.1 MariaDb 10.1.26 — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#3>, or mute the thread https://github.com/notifications/unsubscribe-auth/AKu2pGJEb-mZAt9jXoy7f1c6mLMpcMp3ks5u8uqAgaJpZM4ZhUoC .

您好,更新为 MariaDB 10.3 后安装全部成功,但是使用时提示 : Request failed :error

请教如何处理,并且 nginx 应该如何设置伪静态,当前我是直接把 .htaccess 内的规则做了下转换。

另外,我想设置长度最短为 3-15位,应该如何设置,我把 URL_MIN_LENGTH 设置为 3 好像无法生效。

qianjigit avatar Dec 26 '18 06:12 qianjigit

你好

关于自定义网址长度限制修改

对应的配置参数是 TOKEN_MIN_LENGTHTOKEN_MAX_LENGTH,需要同时修改 config.inc.phpstatic/config.js 这两个配置文件

URL_MIN_LENGTHURL_MAX_LENGTH是用于限制原始网址长度的参数

关于错误信息

应该是没有启用伪静态,导致的接口地址404

Nginx 的伪静态重写规则

我用的是apache,nginx 只用于透明代理。你可以参考 NGINX中的proxy_pass和rewrite 来重写伪静态配置。

需要重写的apache规则文件在 .htaccess

newnius avatar Dec 26 '18 08:12 newnius

感谢,修正 nginx 伪静态后正常使用

rewrite ^/api$ /404.php;
rewrite ^/about$ /404.php;
rewrite ^/pricing$ /404.php;
rewrite ^/admin$ /404.php;
rewrite ^/login$ /404.php;
rewrite ^/service$ /ajax.php;
rewrite ^/auth$ /auth.php;
rewrite ^/help$ /help.php;
rewrite ^/ucenter$ /ucenter.php;
rewrite ^/([0-9a-zA-Z]+)$ /redirect.php?token=$1;

qianjigit avatar Dec 26 '18 10:12 qianjigit

感谢,修正 nginx 伪静态后正常使用

rewrite ^/api$ /404.php;
rewrite ^/about$ /404.php;
rewrite ^/pricing$ /404.php;
rewrite ^/admin$ /404.php;
rewrite ^/login$ /404.php;
rewrite ^/service$ /ajax.php;
rewrite ^/auth$ /auth.php;
rewrite ^/help$ /help.php;
rewrite ^/ucenter$ /ucenter.php;
rewrite ^/([0-9a-zA-Z]+)$ /redirect.php?token=$1;

请教一下您的伪静态是怎么写的。 我现在的情况是点登陆这些会要求下载undefined的文件,缩短地址也会出现something wrong的提示。 不知道是不是伪静态的问题,盼回。

jakkpop avatar Jul 20 '19 14:07 jakkpop

@newnius 您好,请问我如果想修改自定义短网址支持带.和-这2个标点符号,应该如何修改?谢谢

Yuanyiis avatar Aug 31 '19 09:08 Yuanyiis

@newnius 您好,请问我如果想修改自定义短网址支持带.和-这2个标点符号,应该如何修改?谢谢

你好,多谢关注。需要修改以下几处正则表达式:

https://github.com/newnius/short-link/blob/6e7d6424281dd20a522da2629d0e221ee062c295/static/link.js#L29

/^([a-zA-Z0-9]\.-)+$/

https://github.com/newnius/short-link/blob/6e7d6424281dd20a522da2629d0e221ee062c295/.htaccess#L17

RewriteRule ^([0-9a-zA-Z\.-]+)$ /redirect.php?token=$1

.- 都是特殊字符,需要转义。

newnius avatar Aug 31 '19 11:08 newnius

@newnius 非常棒!特别感谢您写了这么好的系统!终于可以用上我的短域名了!哈~ 对了,如果我想实现生成的域名带上个前缀怎么办呢?譬如现在是www.short.com/abc123 我想改成www.short.com/?u=abc123 这样呢?

Yuanyiis avatar Sep 01 '19 02:09 Yuanyiis

@newnius 非常棒!特别感谢您写了这么好的系统!终于可以用上我的短域名了!哈~ 对了,如果我想实现生成的域名带上个前缀怎么办呢?譬如现在是www.short.com/abc123 我想改成www.short.com/?u=abc123 这样呢?

你试试看这样行不行,不太确定

https://github.com/newnius/short-link/blob/6e7d6424281dd20a522da2629d0e221ee062c295/.htaccess#L17

RewriteRule ^\?u=([0-9a-zA-Z]+)$ /redirect.php?token=$1

如果不行的话,就需要在index.php里把redirect.php文件内容复制进去再修改一下了。

其他需要修改的地方

https://github.com/newnius/short-link/blob/6e7d6424281dd20a522da2629d0e221ee062c295/static/main.js#L53

newnius avatar Sep 01 '19 09:09 newnius

@newnius 您好,我按照您的方法修改后,前台设置自定义网址的时候,提示无效的自定义网址,只支持字母,数字。

short-link/static/link.js Line 29 in 6e7d642 var pattern = /^([a-zA-Z0-9])+$/; /^([a-zA-Z0-9].-)+$/ short-link/.htaccess Line 17 in 6e7d642 RewriteRule ^([0-9a-zA-Z]+)$ /redirect.php?token=$1 RewriteRule ^([0-9a-zA-Z.-]+)$ /redirect.php?token=$1 . 和 - 都是特殊字符,需要转义。

Yuanyiis avatar Sep 03 '19 13:09 Yuanyiis

我测试了下,是可以的。

这个错误是 static/link.js 文件里的,你看下有没有修改对应的正则,如果已经修改了,可能是浏览器缓存,你试下清空浏览器缓存。

newnius avatar Sep 03 '19 14:09 newnius

@newnius

//var pattern = /^([a-zA-Z0-9].-)+$/; var pattern = /^([a-zA-Z0-9].-)+$/; if (!pattern.test(token)) { $("#form-link-msg").html("无效的自定义网址,仅支持字母、数字"); return true;

是改成这样么?我这边换了浏览器还是提示那个错误~尴尬~我是小白 不好意思啊

Yuanyiis avatar Sep 04 '19 11:09 Yuanyiis

/^([a-zA-Z0-9]\.-)+$/

你没加转义字符

newnius avatar Sep 04 '19 12:09 newnius

@newnius

/^([a-zA-Z0-9].-?:)+$/

您的意思是这样么?貌似我这样弄了还是不行.... 真抱歉耽误您时间了。

Yuanyiis avatar Sep 05 '19 05:09 Yuanyiis

呀? 反斜杠被自动过滤了。。。。。我刚才明明再每个标点符号前面加上了反斜杠。。

Yuanyiis avatar Sep 05 '19 05:09 Yuanyiis

呀? 反斜杠被自动过滤了。。。。。我刚才明明再每个标点符号前面加上了反斜杠。。

可能是IDE自动处理掉了吧

newnius avatar Sep 06 '19 14:09 newnius