刚刚上班,师父叫在centos上装个oracle11gr2,搞了三四天,总算装好了,却遗留一个sqlplus乱码的问题。初步原定定位在选择字符集的时候,我当时选的是UTF8。
我把数据库删除了,重新建立,到那一步选择了系统默认,结果还是出现乱码。
我再来一次 直接选择了ZHS16GBK,结果还是一样。
其实一直搞错了,刚开始我选择了utf-8,由于Centos默认应该是GBK,所以显示的问号。
现在只需要一个方法
编辑并运行.bash_profile
从oracle官方文档了解到NLS_LANG变量的功能是
Specifies the language, territory, and character set of the client
environment. The client character set specified by NLS_LANG must match
the character set of the terminal or terminal emulator. If required, NLS_
LANG can be temporarily reset to another character set before starting a
non-interactive batch program to match the character set of files and
scripts processed by this program. The character set specified by NLS_LANG
can be different from the database character set, in which case the
character set is automatically converted.export
根据创建数据库时选择的字符集修改NLS_LANG变量
如果是UTF-8:exiport NLS_LANG=AMERICAN_AMERICA.UTF8
如果是 GBK: export NLS_LANG=american_america.ZHS16GBK)
注销后生效
这样再重新进入sqlplus
已经不会是乱码。
博主在CentOS系统中安装Oracle11g后遇到SQLPLUS显示乱码的问题,尝试了多次修改字符集设置,包括选择UTF8、GBK等,但仍然无法解决。通过查阅Oracle官方文档,了解到NLS_LANG变量的作用,该变量用于指定客户端环境的语言、地区和字符集。为匹配数据库字符集,博主尝试设置NLS_LANG为数据库创建时的字符集,如AMERICAN_AMERICA.UTF8或AMERICAN_AMERICA.ZHS16GBK,但问题依然存在。最后,博主发现可能是初始选择的字符集与CentOS默认不一致导致,通过正确设置NLS_LANG环境变量并注销后,解决了乱码问题。

2520

被折叠的 条评论
为什么被折叠?



