我有一个 docker-compose 文件和一个 Dockerfile。MySQL 已正确安装。我已经设置了MYSQL_ROOT_PASSWORD。但是当尝试访问 mysql db 时,出现错误 - 访问被拒绝。我已阅读本网站的其他主题,但无法获得太多帮助。:(
这是我的 docker-compose 文件:
version: '3'
volumes:
db_data: {}
services:
db:
build:
context: .
dockerfile: ./db/Dockerfile
args:
- database=iTel
- password=123
image: db_image
volumes:
- db_data:/var/lib/mysql
ports:
- "3306:3306"
Run Code Online (Sandbox Code Playgroud)
和 Dockerfile:
FROM mysql:5.7.15
ARG database
ARG password
RUN echo ${database}
RUN echo ${password}
MAINTAINER me
ENV MYSQL_DATABASE=${database} \
MYSQL_ROOT_PASSWORD=${password}
ADD ./db/database100.sql /docker-entrypoint-initdb.d
EXPOSE 3306
Run Code Online (Sandbox Code Playgroud)
以下是构建日志:
docker-compose up -d
Building db
Step 1/9 : FROM mysql:5.7.15
5.7.15: Pulling from library/mysql …Run Code Online (Sandbox Code Playgroud) 我实际上丢失了我的root密码,我需要更改它.我按照以下步骤操作:
步骤#1:停止MySQL服务器进程.
步骤#2:使用--skip-grant-tables选项启动MySQL(mysqld)服务器/守护程序进程,以便它不会提示输入密码.
步骤#3:以root用户身份连接MySQL服务器.
我们可以在这些网站上找到:https://www.howtoforge.com/setting-changing-resetting-mysql-root-passwords#recover-mysql-root-password
mysql> use mysql;
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("TOOR");
mysql> flush privileges;
mysql> quit
Run Code Online (Sandbox Code Playgroud)
第一个错误,所以我试过:
mysql> use mysql;
mysql> update user set password=PASSWORD("TOOR") where User='root';
mysql> flush privileges;
mysql> quit
Run Code Online (Sandbox Code Playgroud)
总是同样的错误说:
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 '("TOO
R") WHERE User='root'' at line 1
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我试图通过JHipster创建一个项目并将其部署到Openshif.一切似乎都很正常,但是当运行mvn spring-boot:run或从IDE运行时,没有与MySQL数据库的连接.
错误是:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.annotation.ProxyCachingConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.Collection org.springframework.cache.annotation.AbstractCachingConfiguration.cacheManagerBeans; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheConfiguration': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'liquibase' defined in class path resource [ee/st/running/config/DatabaseConfiguration.class]: Unsatisfied dependency expressed …Run Code Online (Sandbox Code Playgroud)