替换 mysql 数据库中的字符
我已将大型 phpbb3 数据库从 latin1 数据库转移到 utf-8 一切顺利,现在我需要更改数据库中的“奇怪”字符。昨天我找到了一个有效的方法,现在我找不到了,我尝试过:
update phpbb_topics set topic_title = replace(topic_title, 'Ã', 'à');
update phpbb_topics set topic_title = replace(topic_title, 'è', 'è');
基本上我需要将表字段中的所有 à 字符更改为 à 等。
你怎么能这样做呢?
谢谢
I have transfered a big phpbb3 database from a latin1 database to an utf-8
Everything went ok, now I need to change the "strange" characters in the database. Yesterday I found a method that worked, now I can't find it anymore, I tried:
update phpbb_topics set topic_title = replace(topic_title, 'Ã', 'à');
update phpbb_topics set topic_title = replace(topic_title, 'è', 'è');
Basically I need to change all the à characters in the table field to à and so on.
How can you do this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更新 phpbb_topics 设置 topic_title = 替换(replace(topic_title, 'è', 'è'), 'à', 'à');
您应该回答自己以下问题:
update phpbb_topics set topic_title = replace(replace(topic_title, 'è', 'è'), 'Ã', 'à');
You should answer yourself following questions:
我会将其转储到 .sql 文件,然后用 sed 或文本编辑器替换字符(如果文件不太大)。之后再次运行该脚本。
也许有一种方法可以直接在数据库中执行此操作,但我不知道。
我的解决方案的问题在于它不是原子的。转储和重新插入之间对数据库的更改将会丢失。
问候
拉斐尔
I would dump it to a .sql file and then replace the chars with sed or a text editor( if the file is not to large). After that you run the script again.
Maybe there is a way to do this in the database directly but I don't know it.
The problem about my solution is that its not atomic. Changes to the db between the dump and the reinsertion are lost.
Greetings
Raffael