下载了ecshop的数据库,不小心多了个后缀ecs_ 。看着闹心要去掉这条后缀,于是用一下语句:
alter table ecs_user rename user;
当然也可以写成 rename to user,执行效果一样的。但是逐条修改太慢了,于是想批量。一下语句,可以生成批量修改的sql:
SELECT
CONCAT(
'ALTER TABLE ',
table_name,
' RENAME TO ',
substring(table_name, 5),
';'
) sqls
FROM
information_schema.tables Where table_name LIKE 'ecs_%';
执行结果如下:
| ALTER TABLE ecs_error_log RENAME TO error_log; |
| ALTER TABLE ecs_exchange_goods RENAME TO exchange_goods; |
| ALTER TABLE ecs_favourable_activity RENAME TO favourable_activity; |
| ALTER TABLE ecs_feedback RENAME TO feedback; |
| ALTER TABLE ecs_friend_link RENAME TO friend_link; |
| ALTER TABLE ecs_group_goods RENAME TO group_goods; |
| ALTER TABLE ecs_plugins RENAME TO plugins; |
| ALTER TABLE ecs_sessions_data RENAME TO sessions_data; |
| ALTER TABLE ecs_shop_bind RENAME TO shop_bind; |
| ALTER TABLE ecs_shop_config RENAME TO shop_config; |
| ALTER TABLE ecs_snatch_log RENAME TO snatch_log; |
| ALTER TABLE ecs_sns RENAME TO sns; |
| ALTER TABLE ecs_stats RENAME TO stats; |
| ALTER TABLE ecs_suppliers RENAME TO suppliers; |
+--------------------------------------------------------------------+
去掉两边的线段,复制到终端执行就搞定了
附加一条修改mysql的默认密码:update user set Password=password("123456") where User='root';