酷符网数据库 > 正文

mysql更改database名

2011-03-17 13:31codeif.com

我用的数据库是mysql5.1.26
根据网上的rename database 原来的database名 to 新的database名,会出现下面的错误

mysql> rename database jeecms to jeecms2;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'datab
ase jeecms to jeecms2' at line 1

看来方法行不通,只能用别的方法

我们可以先创建目标database
假设原来的database是srcdb,改为targetdb,首先

create database targetdb;

然后将所有的表执行下面的语句

rename table srcdb.[tablename] to targetdb.[tablename];

相关文章

新浪微博 | 淘段子 | 我的博客 | 淘宝店铺 | jnan.org | RSS
Copyright © 2009 - 2011 酷符网