我在远程服务器上安装了Mysql数据库(IP: 172.17.56.104)(Mysql没有容器)。我还有一个Selenium项目要运行测试,当测试运行时,测试结果会插入到数据库中。一切都正常。现在我封装Selenium项目并使用docker运行测试,它显示了连接到数据库的超时,我猜容器中的代码无法连接到远程数据库。希望有人能给我个建议。
Dockerfile:
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app
EXPOSE 4444
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS
是否可以远程连接到云运行容器中的MySQL?
详细信息
Server 1 (slave server) - I have a Docker container (in Google Cloud Run) with MySQL-Server in it.
|
|
|
Server 2 (main server) - I want to connect to MySQL via PHP.
有可能这样做吗?
P.s
我试着去做,但我做不到。
PhpStorm 2018.2.3
我尝试在PhpStorm中使用xdebug。
Dockerfile
FROM php:7.0-apache
RUN pecl install -o -f redis
RUN pecl install -o -f xdebug
RUN docker-php-ext-enable redis
RUN docker-php-ext-enable xdebug
RUN docker-php-ext-install pdo pdo_mysql mysqli
RUN apt-get update
RUN apt-get install locales-all -y
我有一个运行Ubuntu的DigitalOcean液滴,我在它上安装了MySQL。我可以通过MySQL工作台通过SSH连接从我的计算机到达它,所以远程访问是可以的。主机名为127.0.0.1
The bind address in my mysqld.cnf: 127.0.0.1
我有一个.NET核心API,我想使用Docker来运行它。我把集装箱推到码头枢纽,把它拉到水滴上。当我试图运行时,我会得到以下错误:
使用与数据库的连接“在服务器‘127.0.0.1’上发生错误。
我的连接字符串:
"Server=127.0.0.1;Port=3306;Database=db;Uid=us
我正在使用以下设置
远程系统
- Running "rootless Docker"
- Docker context named "rootless" being active
- VS Code Docker extension being installed
VS代码-使用“远程扩展”通过SSH连接到远程计算机
- Building and runing the Docker container using rootless Docker
- Checking that the "rootless" Docker context is se
我正在尝试连接到远程托管的mysql,但docker run没有加载驱动程序,给出了classnotfounderror。
ClassNotFoundException: com.mysql.cj.jdbc.Driver
appreciate help! thanks.
--
FROM java:8-jdk-alpine
RUN apk get update
RUN apk --no-cache add curl
RUN curl -L -o /mysql-connector-java-5.1.34.jar https://repo1.maven.org/maven2/mysql/mysql
使用Desktop,我启动了一个mysql/mysqlserver.容器
docker run --name=mysqlproject -e MYSQL_ROOT_HOST=% -p 3306:3306 -d mysql/mysql-server
然后我为我的数据库创建了一些用户.
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
create user 'dev'@'%' identified by 'password';
grant
在我的本地计算机上,我可以使用mysql cli命令轻松地连接到mysql数据库的远程实例(假设设置了环境变量):
# mysql -u root -p$DB_PASSWORD -h $DB_HOST --port=$DB_PORT
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7365
Server ver
我正在运行一个需要远程MySQL DB的SpringBoot应用程序。当运行jar文件时,它正在工作。但是,当我尝试将springboot应用程序容器化时,它给出了SQLNonTransientConnectionException。我的Docker设置在Windows OS机器上。
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
at com.mysql.cj.jdbc.exc