Problems encountered in deploying the project to Linux

1. Local Navicat for MySQL cannot connect to the server (CentOS 7 x86_64 BBR)

1045 error:

Solution steps:

1. Check whether the user name and password are wrong

2. If the user name and password are correct, log in to the server remotely and enter mysql,

MysqL> use MysqL;
Database changed
MysqL> grant all privileges  on *.* to root@'%' identified by "password";
Query OK,0 rows affected (0.00 sec)

MysqL> flush privileges;
Query OK,0 rows affected (0.00 sec)

MysqL> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host         | user | password                                  |
+--------------+------+-------------------------------------------+
| localhost    | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| 192.168.1.1 | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| %            | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
+--------------+------+-------------------------------------------+
3 rows in set (0.00 sec)

grant all privileges on *.* to root@'%' identified by "password";

The above sentence means that all IP can remotely access MySQL on the machine with user name root password Of course, you can customize your password

Above, the problem is basically solved (that's how I solved it. If your problem hasn't been solved, Google again)

2. After being deployed to the server (CentOS 7 x86_64 BBR), the form submits garbled code

This problem is disgusting Because the local development environment is tomcat7 development, and my server is tomcat8, I checked a lot on the Internet What 7 -- > 8 should be in service XML change configuration encoding It's useless. I'm going to give up Thought it was the coding reason of foreign servers then... It suddenly occurred to me that there might be a problem behind the URL when JDBC connects to the database

customary

<property name="user">root</property>
<property name="password">root</property>
<property name="driverClass">com.MysqL.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:MysqL://ip地址:3306/class3</property>

Add parameter to jsbcurl? Useunicode = true & characterencoding = UTF-8, but in XML & Use & amp; Replaced by:

<property name="user">root</property>
<property name="password">root</property>
<property name="driverClass">com.MysqL.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:MysqL://ip地址:3306/class3?useUnicode=true&amp;characterEncoding=UTF-8</property>

Principle:

We add this to specify the encoding and decoding format of characters.

For example, the MySQL database uses GBK encoding, while the project database uses UTF-8 encoding. In this case, if useunicode = true & characterencoding = UTF-8 is added, the functions are as follows:

When saving data:

When storing project data, the database will first decode the data into bytecode in UTF-8 format, and then store the decoded bytecode in the database again in GBK coding.

When retrieving data:

When fetching data from the database, the database will first decode the data in the database into bytecode in GBK format, then re encode the decoded bytecode in UTF-8 format, and finally return the data to the client.

Above, solve

EMM, pit filling + 2

good night

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>