想裝個(gè)小說(shuō)站來(lái)玩玩,,結(jié)果數(shù)據(jù)庫(kù)是 postgresql,到創(chuàng)建數(shù)據(jù)庫(kù)的時(shí)候出現(xiàn)如下錯(cuò)誤
“ERROR: new encoding (UTF8) is incompatible with the encoding of the template”
網(wǎng)上查了下,,大概說(shuō)的是系統(tǒng)默認(rèn)沒(méi)有設(shè)置為 utf8 的話(huà)就會(huì)出現(xiàn)這個(gè)錯(cuò)誤,。
解決的方法也很簡(jiǎn)單,,刪了在從重新創(chuàng)建一個(gè)就好。
步驟如下:
1.首先,,我們需要?jiǎng)h除template1的,。模板不能被刪除,所以我們首先修改它,,設(shè)置成一個(gè)普通的數(shù)據(jù)庫(kù): 登陸postgresql [root@ root]# su - postgres,; -bash-4.1$ psql postgres=# UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1'; 2.現(xiàn)在,我們可以刪除它: postgres=# DROP DATABASE template1; 3.然后,,重新創(chuàng)建一個(gè)template1數(shù)據(jù)庫(kù),,設(shè)置默認(rèn)編碼: postgres=# CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE'; 4.在把template1設(shè)置成為默認(rèn)模板。 postgres=# UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1'; 5.最后切換模板就可以了 postgres=# \c template1 template1=# VACUUM FREEZE; template1=# \q1.首先,我們需要?jiǎng)h除template1的,。模板不能被刪除,,所以我們首先修改它,設(shè)置成一個(gè)普通的數(shù)據(jù)庫(kù): 登陸postgresql [root@ root]# su - postgres,; -bash-4.1$ psql postgres=# UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1'; 2.現(xiàn)在,,我們可以刪除它: postgres=# DROP DATABASE template1; 3.然后,重新創(chuàng)建一個(gè)template1數(shù)據(jù)庫(kù),,設(shè)置默認(rèn)編碼: postgres=# CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE'; 4.在把template1設(shè)置成為默認(rèn)模板,。 postgres=# UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1'; 5.最后切換模板就可以了 postgres=# \c template1 template1=# VACUUM FREEZE; template1=# \q
到這里應(yīng)該就可以了
作者:fly
鏈接:https://hacpai.com/article/1478711156804
來(lái)源:黑客派
著作權(quán)歸作者所有。商業(yè)轉(zhuǎn)載請(qǐng)聯(lián)系作者獲得授權(quán),,非商業(yè)轉(zhuǎn)載請(qǐng)注明出處,。