[英]Error Code: 1005 Can't create table users (errno: 150)
当我运行此查询时:
DROP TABLE IF EXISTS `users`;
然后:
CREATE TABLE `users` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`role_id` int(11) NOT NULL DEFAULT '4',
`email` varchar(120) NOT NULL,
`username` varchar(30) NOT NULL DEFAULT '',
`password_hash` char(60) NOT NULL,
`reset_hash` varchar(40) DEFAULT NULL,
`last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`last_ip` varchar(40) NOT NULL DEFAULT '',
`created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`reset_by` int(10) DEFAULT NULL,
`banned` tinyint(1) NOT NULL DEFAULT '0',
`ban_message` varchar(255) DEFAULT NULL,
`display_name` varchar(255) DEFAULT '',
`display_name_changed` date DEFAULT NULL,
`timezone` char(4) NOT NULL DEFAULT 'UM6',
`language` varchar(20) NOT NULL DEFAULT 'english',
`active` tinyint(1) NOT NULL DEFAULT '0',
`activate_hash` varchar(40) NOT NULL DEFAULT '',
`password_iterations` int(4) NOT NULL,
`force_password_reset` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
我得到错误:
错误代码:1005
无法创建表“ admin_sc.users”(错误号:150)
检查了/ var / lib / mysql / admin_sc目录的权限-可以使用其他名称创建表,但不能创建表users
有什么可以帮助的吗? 我的查询中没有任何外键。
$ perror 105
OS error code 105: No buffer space available
$
确定要删除“用户”,而不是“ bf_users”吗?
也可能只是InnoDB表空间已损坏。 我会在另一台机器上尝试相同的操作,以查看问题是否可重复。 至少对我有用:
MariaDB [(none)]> create database testt;
Query OK, 1 row affected (0.04 sec)
MariaDB [(none)]> use testt;
Database changed
MariaDB [testt]> CREATE TABLE `users` (
-> `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
-> `role_id` int(11) NOT NULL DEFAULT '4',
-> `email` varchar(120) NOT NULL,
-> `username` varchar(30) NOT NULL DEFAULT '',
-> `password_hash` char(60) NOT NULL,
-> `reset_hash` varchar(40) DEFAULT NULL,
-> `last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
-> `last_ip` varchar(40) NOT NULL DEFAULT '',
-> `created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
-> `deleted` tinyint(1) NOT NULL DEFAULT '0',
-> `reset_by` int(10) DEFAULT NULL,
-> `banned` tinyint(1) NOT NULL DEFAULT '0',
-> `ban_message` varchar(255) DEFAULT NULL,
-> `display_name` varchar(255) DEFAULT '',
-> `display_name_changed` date DEFAULT NULL,
-> `timezone` char(4) NOT NULL DEFAULT 'UM6',
-> `language` varchar(20) NOT NULL DEFAULT 'english',
-> `active` tinyint(1) NOT NULL DEFAULT '0',
-> `activate_hash` varchar(40) NOT NULL DEFAULT '',
-> `password_iterations` int(4) NOT NULL,
-> `force_password_reset` tinyint(1) NOT NULL DEFAULT '0',
-> PRIMARY KEY (`id`),
-> KEY `email` (`email`)
-> ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (1.33 sec)
MariaDB [testt]>
我建议您执行一个脚本,该脚本删除表“ users”(检查它是否不存在),然后重新创建该表
或如Nishanthi所说..尝试用其他名称创建此表,它可能会起作用
在我看来,这可能是因为users
表是为某些系统相关表保留的。
users
更改为其他名称。 DROP TABLE IF EXISTS users
,然后创建表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.