version: "3"
services:
mysql:
image: mysql:8.0.36
environment:
MYSQL_ROOT_USER: root
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: topdom
command: --init-file db/initDB.sql
ports:
- "3306:3306"
tomcat:
build: .
ports:
- "8080:8080"
app:
image: openjdk:17
container_name: "java-app"
FROM tomcat:9.0.59-jdk17-openjdk
COPY ./target/application.war /usr/local/tomcat/webapps/
CMD ["catalina.sh", "run"]
mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON *.* TO 'vadim'@'%' IDENTIFIED BY 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'root'' at line 1
mysql> GRANT ALL PRIVILEGES ON *.* TO 'vadim'@'127.0.0.1' IDENTIFIED BY 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'root'' at line 1
mysql> grant all on *.* to `vadim`@`127.0.0.1` identified by 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'root'' at line 1
mysql> grant all on *.* to `root`@`%` identified by 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'root'' at line 1
mysql> grant all on *.* to `root`@`127.0.0.1` identified by 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'root'' at line 1
13-Feb-2024 16:15:37.944 INFO [http-nio-8080-exec-4] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
13-Feb-2024 16:15:38.287 INFO [http-nio-8080-exec-4] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
13-Feb-2024 16:15:58.306 SEVERE [http-nio-8080-exec-4] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jdbc.datasource.init.DataSourceInitializer#0': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
13-Feb-2024 16:15:58.317 SEVERE [http-nio-8080-exec-4] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
13-Feb-2024 16:15:58.320 SEVERE [http-nio-8080-exec-4] org.apache.catalina.core.StandardContext.startInternal Context [/application] startup failed due to previous errors
13-Feb-2024 16:15:58.402 WARNING [http-nio-8080-exec-4] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [application] registered the JDBC driver [com.mysql.cj.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
13-Feb-2024 16:15:58.407 WARNING [http-nio-8080-exec-4] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [application] appears to have started a thread named [mysql-cj-abandoned-connection-cleanup] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@17.0.9/java.lang.Object.wait(Native Method)
java.base@17.0.9/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155)
com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:91)
java.base@17.0.9/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base@17.0.9/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base@17.0.9/java.lang.Thread.run(Thread.java:840)
13-Feb-2024 16:15:58.410 WARNING [http-nio-8080-exec-4] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesObjectStreamClassCaches Failed to clear soft references from ObjectStreamClass$Caches for web application [application]
java.lang.ClassCastException: class java.io.ObjectStreamClass$Caches$1 cannot be cast to class java.util.Map (java.io.ObjectStreamClass$Caches$1 and java.util.Map are in module java.base of loader 'bootstrap')
root@vdska:~# mysql -h 127.0.0.1 -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'
DESCRIBE mysql.user; SELECT user FROM mysql.user; SELECT user();
+------------------+
| user |
+------------------+
| debian-sys-maint |
| mysql.infoschema |
| mysql.session |
| mysql.sys |
| root |
+------------------+
5 rows in set (0,01 sec)
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0,00 sec)
В общем, решил я настроить через docker, и столкнулся с теми же эксепшенами... Несколько часов мучений, уже на рабочем компьтере, я решил перепроверить работает ли проект, и столкнулся с теми же эксепшенами уже только на виндовс, нашел корень проблемы, решил благодаря этому видео, теперь только пока не понимаю как решить эту проблему в docker и в ubuntu ... Как настроить server mysql?
docker-compose.yml
Dockerfile