Openfire is a very good IM server, and it is implemented in pure Java and has multiple platform versions. Its data storage can use a variety of databases, such as MySQL and Oracle.
In actual use, the most common problem encountered is the garbled Chinese characters after the MySQL database. This problem is very interesting, and we can see some internal mechanisms of Openfire.
The actual problem is as follows: first start the Openfire server, and then use the client or directly log on to the background to create an account, specifying some Chinese attributes for the account, such as the name. If you do not restart the server, you will never find anything wrong, because all Chinese characters are displayed normally. Next, restart Openfire and log on to the client with the created account or go to the background management terminal to view the information. All Chinese characters are changed to question marks. Log on to the database and check that all Chinese characters are question marks. This illustrates two problems:
- Openfire has application-layer Cache
- Database Encoding Problems
The solution is actually very simple. First, make sure that the database code you created for openfire is utf8. The table creation statement is as follows:
Create database openfire default character set utf8 default collate utf8_general_ci
When you have created a database, you can use:
Alter database openfire default character set utf8 default collate utf8_general_ci;
Second, when initializing the Openfire database, that is, when the Openfire server is configured for the first time, the connection string connecting to the database must be in the character encoding format and the UTF-8 encoding requirements must be added to the connection, set the connection string as follows:
Jdbc: mysql: // 127.0.0.1: 3306/openfire? UseUnicode = true & characterEncoding = utf8
If the installation is complete, you can change the configuration. Go to the Openfire installation directory and find conf/openfire. open the following xml section and modify the serverURL.
<Database>
<DefaultProvider>
<Driver> com. mysql. jdbc. Driver </driver>
<ServerURL> jdbc: mysql: // 127.0.0.1: 3306/openfire? UseUnicode = true & amp; characterEncoding = utf8 </serverURL>
Note: Because & has special meanings, the original & symbol must be escaped as & amp;
Openfire details: click here
Openfire: click here
Detailed installation process of Openfire in CentOS
Openfire server configuration notes based on Jabber/XMPP protocol in CentOS 5.4
Install Openfire on Ubuntu 12.04