ubuntu改变区域后对Postgresql的影响

来源:互联网 发布:华为软件官网 编辑:程序博客网 时间:2024/05/23 15:11
没改变之前区域显示
ubuntu@vm172-31-0-9:~$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=


数据库显示
 Name      |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 Harvest   | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres+
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres+
           |          |          |             |             | postgres=CTc/postgres
 testdb    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |




中文数据库显示

   Name    |  Owner   | Encoding |                       Collate                       |                        Ctype                        |   Access privileges
-----------+----------+----------+-----------------------------------------------------+-----------------------------------------------------+-----------------------
 Harvest   | postgres | UTF8     | Chinese (Simplified)_People's Republic of China.936 | Chinese (Simplified)_People's Republic of China.936 |
 postgres  | postgres | UTF8     | Chinese (Simplified)_People's Republic of China.936 | Chinese (Simplified)_People's Republic of China.936 |
 template0 | postgres | UTF8     | Chinese (Simplified)_People's Republic of China.936 | Chinese (Simplified)_People's Republic of China.936 | =c/postgres          +
           |          |          |                                                     |                                                     | postgres=CTc/postgres
 template1 | postgres | UTF8     | Chinese (Simplified)_People's Republic of China.936 | Chinese (Simplified)_People's Republic of China.936 | =c/postgres          +
           |          |          |                                                     |                                                     | postgres=CTc/postgres
 testdb    | postgres | UTF8     | Chinese (Simplified)_People's Republic of China.936 | Chinese (Simplified)_People's Republic of China.936 |
(5 rows)




vim /var/lib/locales/supported.d/local
添加
zh_CN.GBK GBK
zh_CN.GB2312 GB2312
zh_CN.UTF-8 UTF-8
使生效
sudo dpkg-reconfigure --force locales


然后重新生成locale
$sudo locale-gen




期间还安装了三个包
支持中文装三个包
sudo apt-get install language-selector language-env language-pack-zh
但发现不能用,最后执行下面这个指令
sudo apt-get install language-pack-zh-hant language-pack-zh-hans language-selector-gnome


新建一个目录data1


sudo mkdir /usr/local/pgsql/data1
sudo chown postgres /usr/local/pgsql/data1
export PATH=/usr/local/pgsql/bin/:$PATH
export PGDATA=/usr/local/pgsql/data1
初始化数据库
initdb


再看数据库,变成zh_CN.UTF-8
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 harvest   | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 |
 harvest1  | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 |
 postgres  | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 |
 template0 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(5 rows)
0 0
原创粉丝点击