我有一个小的mariadb SQL初始化脚本,它以这样的方式开始:
drop user if exists 'uslmonitor';
drop database if exists uslmonitordb;
create database uslmonitordb;
此失败并出现此错误:
ERROR 1064 (42000) at line 1: 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 'if exists 'uslmonitor'' at line 1
我在盒子上检查了mysql / mariadb的版本,它说:
mysql Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1
更新:
好的,我已将MariaDB升级为“10.1.21-MariaDB-1~jessie”(我喜欢Docker),我的init脚本摘录现在是这样的:
drop user if exists 'uslmonitor';
drop database if exists uslmonitordb;
flush privileges;
create database uslmonitordb;
create user 'uslmonitor'@localhost identified by 'uslmonitor';
这是失败的:
ERROR 1396 (HY000) at line 7: Operation CREATE USER failed for 'uslmonitor'@'localhost'