我需要从旧用户数据库迁移到新用户数据库....但幸运的是密码和盐字段的值在两者上都相同,但列名称不同(在旧表上:user passhash - >秘密,在新表上:newuser password-> salt)
如何从现有用户数据生成插入转储?每当我做
之类的事情SELECT id,
username,
LOWER(username) AS username_canonical,
email,
LOWER(email) AS email_canonical,
passhash AS 'password',
secret AS salt,
1 AS enabled,
'a:0:{}' AS roles,
0 AS credentials_expired,
0 AS expired,
0 AS locked,
uploaded,
downloaded,
torrent_pass,
0 AS torrent_pass_version
FROM
temp2.users AS fos_user
WHERE enabled = 'yes' ;
我可以看到phpMyAdmin中正确列出的值...但是当我导出结果时,我看到旧结构中的插入:
INSERT INTO `fos_user` (`id`, `username`, `username`, `email`,
`email`, `passhash`, `secret`, `enabled`, `a:0:{}`,
`credentials_expired`, `expired`, `locked`, `uploaded`,
`downloaded`, `torrent_pass`, `torrent_pass_version`)
VALUES....
答案 0 :(得分:1)
为什么不同时执行INSERT和SELECT:
INSERT INTO `fos_users` (username, password, salt ...)
SELECT LOWER(username), passhash, secret, ...
FROM users;
当然,这假设您可以在新数据库中拥有旧数据集,至少暂时...
答案 1 :(得分:1)
如果使用phpmyAdmin GUI导出表,它将使用表的原始模式。要使用所需的架构导出它,请使用SELECT INTO文件语法:http://dev.mysql.com/doc/refman/5.1/en/select-into.html