mysql - 迁移数据库到当前版本的MySQL,一个表中有一个保留字

标签 mysql mysql-error-1054

我有这张表是从旧版本的 mysql 迁移过来的:

> SHOW COLUMNS from tbl
(output modified below for posting)

watch_id           | int(11)      | NO   | PRI | NULL  
user_id            | varchar(125) | YES  | MUL | NULL
type               | int(11)      | YES  | MUL | NULL
range              | int(10)      | YES  |     | NULL
active             | tinyint(4)   | NO   |     | 1

“range”在当前版本中是保留字

ALTER TABLE `db`.`tbl` CHANGE COLUMN `range` `watch_range` INT(10) DEFAULT NULL;

结果在

ERROR 1054 (42S22): Unknown column 'range' in 'tbl'

有什么想法吗?

注意:当我最初发布这个时我打错了,sql 有:

`range` not `range' as I originally posted

最佳答案

正如@eggyal建议的那样

ran mysql_upgrade
ran repair

然后

dumped the database and removed it
imported the dump
restarted mysql

成功了,不知道为什么

关于mysql - 迁移数据库到当前版本的MySQL,一个表中有一个保留字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11318540/

相关文章:

java - 使用大量数据提高 hibernate 插入性能的最佳方法

mysql - 如何使用 UNION 选择所有字段(包括 NULL)?

mysql - 整个 mysql 表的唯一键?

mysql - sql子查询问题

mysql - 使用子查询和连接表更新临时表失败

php - 获取 facebook 用户 ID 并从 iOS 应用程序传递到 MySQL?

php限制事件数据库条目

sql - MySQL 左连接错误

php - SQL选择日期范围

mysql子查询字段应用范围