[英]Error with creating tables MySql - (errno: 150)
我對此腳本有疑問。 有人能幫我嗎?
ERROR 1005: Can't create table 'db_new.users_roles' (errno: 150)
SQL Statement:
CREATE TABLE `luxury`.`users_roles` (
`id` INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`))
在數據庫中,有“用戶”和“角色”表。 “ users_roles”是ManyToMany Hibernate的表
這樣嘗試一次
CREATE TABLE IF NOT EXISTS `users_roles` (
`id` int(12) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
也許嘗試以下
select user,host from mysql.user;
show grants for 'root'@'%';
analyze table luxury
optimize table luxury
@Anele這是您的方法返回的結果:
mysql> select user,host from mysql.user;
+------------------+----------------+
| user | host |
+------------------+----------------+
| root | % |
| root | 127.0.0.1 |
| root | 95.110.190.185 |
| root | ::1 |
| admin | localhost |
| debian-sys-maint | localhost |
| root | localhost |
| root | luxury |
| root | somehost |
+------------------+----------------+
9 rows in set (0.00 sec)
mysql> show grants for 'root'@'%';
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@% |
+--------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*CC06F61FF8BD3C6AD10D57E28E340FB097DDD' WITH GRANT OPTION |
+--------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> analyze table luxury;
+---------------+---------+----------+-------------------------------------+
| Table | Op | Msg_type | Msg_text |
+---------------+---------+----------+-------------------------------------+
| luxury.luxury | analyze | Error | Table 'luxury.luxury' doesn't exist |
| luxury.luxury | analyze | status | Operation failed |
+---------------+---------+----------+-------------------------------------+
2 rows in set (0.00 sec)
mysql> optimize table luxury;
+---------------+----------+----------+-------------------------------------+
| Table | Op | Msg_type | Msg_text |
+---------------+----------+----------+-------------------------------------+
| luxury.luxury | optimize | Error | Table 'luxury.luxury' doesn't exist |
| luxury.luxury | optimize | status | Operation failed |
+---------------+----------+----------+-------------------------------------+
2 rows in set (0.00 sec)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.