Linux non-root user C3P0 connection MySQL permission problem

Today I want to move the web project developed under windows to linux for development. The framework used is springmvc+spring+hibernate. Myeclipse deploys the project to tomcat, but throws an exception, console information: java.sql.SQLException: Access denied for user 'canva'@'localhost' (using password: YES) .
At first, I still felt strange, the user configured in db.properties is obviously root, why is it now logged in as the current user of the Debian system? So I switched to the root user to log in to the system again, and found that everything was normal, and the connection was 'root'@'localhost'. So I found the problem, and then I will solve it.
Open the command line interface:

sudo mysql_setpermission

输入数据库root用户密码,之后有如下选项:
1. Set password for an existing user.
2. Create a database + user privilege for that database
and host combination (user can only do SELECT)
3. Create/append user privilege for an existing database
and host combination (user can only do SELECT)
4. Create/append broader user privileges for an existing
database and host combination
(user can do SELECT,INSERT,UPDATE,DELETE)
5. Create/append quite extended user privileges for an
existing database and host combination (user can do
SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,
LOCK TABLES,CREATE TEMPORARY TABLES)
6. Create/append full privileges for an existing database
and host combination (user has FULL privilege)
7. Remove all privileges for for an existing database and
host combination.
(user will have all permission fields set to N)
0. exit this program
Here I choose 4 to create a new name and my current A database user who is the same as the system user and only has permission to add, delete, modify, and query. If you want to get all permissions, please choose 6. Next, just follow the prompts, select one or more databases, fill in the user name and password, and set the connection method (localhost).
In this way, a database user corresponding to its own system user is created, and then the db.properties is changed, and the user and password are set to the newly created user. Examples are as follows:

jdbcUrl=jdbc\:mysql\://localhost\:3306/countryside?useUnicode\=true&characterEncoding\=utf8
driverClass=com.mysql.jdbc.Driver
user=canva
password=123456
initialPoolSize=10
maxPoolSize=30

Then you can connect!

Guess you like

Origin blog.csdn.net/CanvaChen/article/details/52734543