我已安装mySQL Server并创建了一个名为ej_instance
的用户,并设置了密码“password”。使用以下命令登录服务器
mysql -u ej_instance -p;
-- entered password
ej_instance只能访问ejabberd
个数据库。所以我执行了如下命令
use ejabberd;
然后尝试执行如下命令
SET table_type=InnoDB;
CREATE TABLE users (
username varchar(250) PRIMARY KEY,
password text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) CHARACTER SET utf8;
但它给我带来了错误。以下是错误
ERROR 1193 (HY000): Unknown system variable 'table_type'
ERROR 1046 (3D000): No database selected
如何完成这项工作?还有什么要改变的吗?
答案 0 :(得分:3)
创建表时指定引擎类型,如下所示:
USE ejabberd;
CREATE TABLE users (
username varchar(250) PRIMARY KEY,
password text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) CHARACTER SET utf8 ENGINE = INNODB;
如果仍然显示使用错误,请检查:
以root身份登录:
#check the database exists
SHOW DATABASES LIKE 'ejabberd';
#check user permissions
SHOW GRANTS FOR 'ej_instance'@'localhost';
SHOW GRANTS FOR 'ej_instance'@'%';
如果没有足够的权限:
#grant all permission on the user for the specified database
GRANT ALL ON ejabberd.* TO 'ej_instance'@'localhost';
GRANT ALL ON ejabberd.* TO 'ej_instance'@'%';
FLUSH PRIVILEGES;