I have a spring boot application that is connecting to a MySQL db (MySQL 8.0). Here is the connection configuration in my application.yml file
datasource:
url: "jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME}?useUnicode=yes&characterEncoding=UTF-8&autoReconnect=true&useSSL=false"
username: "${DB_USER}"
password: "${DB_PASSWORD}"
hikari:
maximumPoolSize: ${DB_MAX_POOL_SIZE}
I would like to enable compression on this connection pool. How can I achieve that? Not been able to find any documentation on this.
The connection parameter is useCompression. It is a boolean.
Refer to MySQL Connector/J Networking Configuration Properties: useCompression
Related
I start my project with spring boot and camunda and MySQL , but camunda tables cant create .
my config is :
spring:
datasource:
url: jdbc:mysql://localhost:3306/austira
username: root
password: root
jpa:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
database: MYSQL
hibernate:
ddl-auto: update
server:
port: 9090
camunda:
bpm:
database:
type: mysql
then I face with this exception:
Caused by: java.sql.SQLSyntaxErrorException: Table 'austira.act_ge_property' doesn't exist
thanks for your help
Did you create the database austira after starting the database?
Does the user have access to it?
Have the tables not been created during startup or is it only failing later, after the tables have been created and the engine tries to use them (see / provide more startup logs)?
Here is a working setup against MySQL (on Docker):
https://github.com/rob2universe/camunda-mysql
(I changed the db name to camdb instead of austira)
I've got two docker services, one running a simple node server and the other a mysql (mariadb actually) database server.
All instances of a socket file mentioned anywhere in /etc/mysql/ say
/var/run/mysqld/mysqld.sock
This will be important soon.
My node server is running some Sequelize code that is trying to connect to the MySQL server.
Whenever I try and connect via Sequelize, I get:
{"statusCode":500,"error":"Internal Server Error","message":"connect ENOENT /var/run/mysqld/mysqld.sock"}
However, if I log into the Node docker container I can successfully connect to MySQL on the other docker container using the mysql CLI client.
I think I understand that the mysql client is using a tcp connection, while Sequelize is using a socket connection. But, when Sequelize is throwing that error, it is showing the correct socket path, as far as I know. Here is my Sequelize config:
const options = {
host: "mysql",
dialect: "mysql",
dialectOptions: {
socketPath: "/var/run/mysqld/mysqld.sock"
}
};
let sequelize = new Sequelize("ibbr_dev", "devuser", "password", options);
The MySQL socket file is not available in your Node container, it is only available in the MySQL container as it is a file. Rather than setting up unix socket based connection, you should use a TCP connection (skipping the dialectOptions).
I'm using mysql 5.7 on my Mac to develop a springboot app with no problems.
Here are my properties:
logging.level.root=WARN
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR
server.port=8091
spring.datasource.url=jdbc:mysql://localhost:3306/dbName
spring.datasource.username=useraa
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.show-sql=false
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.use-new-id-generator-mappings=true
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.format_sql = false
spring.jpa.properties.hibernate.default_schema=USERAA
After I deploy using mvn clean install and upload to my server on Digital Ocean, this error message shows when I run the .jar with command java -jar app.jar
java.sql.SQLException: Access denied for user 'useraa'#'localhost' (using password: YES)
with ERROR 28538 com.zaxxer.hikari.pool.HikariPool : testdb - Exception during pool initialization.
I checked my firewall settings already and I allow the port and I can connect to mysql using ssh/phpmyadmin with username 'useraa'.
I also tried a CRUD command in ssh.
You are connecting to MySQL but it is not authenticating you.
Check your username and password are correct
Check your username has access from local host
Check your username has privileges to the schema
I am using azure connection string (from Azure portal) for Node.js app, still cannot connect to Azure Database for Mysql server.
var conn = mysql.createConnection({
host: yourhost,
user: "username",
password: "password",
database: "database",
port: 3306,
ssl:{ca:fs.readFileSync(__dirname + '/baltimore.pem')}});
I get following error:
"Error: MySQL server is requesting the old and insecure pre-4.1 auth mechanism.Upgrade the user password or use the {insecureAuth: true} option."
But I can connect using Mysql Benchmark same credentials.
What I am doing wrong ?
Azure Database for MySQL is incompatible with the mysqljs connector library. See issue 1729 for details and pull 1730 for a workaround.
Here is strange problem.
databse server ip : 170.2.14.131
application server ip : 170.2.14.137
Application is on cloud server. Database server is on another instance
and application hosted on different instance.
production:
adapter: mysql
database: database_name
username: ************
password: ************
host: 170.2.14.131
This is my database.yml configuration for production environment.
Now when i am trying to connect through my application it's using
application server IP instead of remote databse IP.
Please suggest.
By default, MySQL database server remote access disabled for security reasons. there're 3 solutions to this problem, i'll not describe them here, you can read about it in my blog here:
http://notes.kloop.kg/2011/11/17/enable-remote-access-to-mysql-database-server/