Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> xampp - connect to external MySQL DB with SSH tunnel - No such file or directory
virgus66
post 7.12.2017, 16:58:37
Post #1





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 7.12.2017

Ostrzeżenie: (0%)
-----


Probowalem wszystkiego i wciz ten sam problem. Udalo mi sie polaczyc z baza przez workbencha, tworzac tunel ssh, ale z apacha wciaz dostaje odpowiedz:

Cytat
ERROR - Connection to DB failed: SQLSTATE[HY000] [2002] No such file or directory


User and pass 100% poprawne, co robie zle?

  1. <?php
  2. try
  3. {
  4. $pdo = new PDO('mysql:127.0.0.1:3306', 'user', 'password');
  5. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  6. $pdo->exec('SET NAMES "utf8"');
  7. echo "Connected!";
  8. }
  9. catch (PDOException $e) {
  10. $error = 'ERROR - Connection to DB failed: ' . $e->getMessage();
  11. echo $error; exit();
  12. }
  13.  
  14. ?>
Go to the top of the page
+Quote Post
Pyton_000
post 7.12.2017, 17:01:57
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


$pdo = new PDO('mysql:host=127.0.0.1', 'user', 'password');
Go to the top of the page
+Quote Post
virgus66
post 7.12.2017, 17:07:06
Post #3





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 7.12.2017

Ostrzeżenie: (0%)
-----


zmienil sie tylko err

Cytat
ERROR - Connection to DB failed: SQLSTATE[HY000] [2002] Connection refused


nie trzeba podawac portu? przy polaceniu przez mysql workbench byl wymagany

Ten post edytował virgus66 7.12.2017, 17:08:02
Go to the top of the page
+Quote Post
Pyton_000
post 7.12.2017, 17:26:31
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


jeśli port jest standardowy to nie
natomiast jeśli musisz podać port to ma to wyglądać tak:

'mysql:host=127.0.0.1;port=3306'
Go to the top of the page
+Quote Post
virgus66
post 7.12.2017, 17:34:14
Post #5





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 7.12.2017

Ostrzeżenie: (0%)
-----


Wciaz zima,
Cytat
Connection refused 2002
....

Gdzies xampp tutaj to polaczenie blokuje, tylko nie wiem gdzie...
Go to the top of the page
+Quote Post
Pyton_000
post 7.12.2017, 17:35:41
Post #6





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


Workbench Ci się łączy na tych danych?
Go to the top of the page
+Quote Post
virgus66
post 7.12.2017, 17:39:32
Post #7





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 7.12.2017

Ostrzeżenie: (0%)
-----


laczy, ale przez szyfrowany tunel ssh. Mam ustanowione to polaczenie :

ssh -L10000:127.0.0.1:10000 ucado-dev@app.ucado.co.uk

ale ja sie na polaczeniach ssh i ustalaniu portow nie znam za bardzo. Mam w konsoli otwarte to polaczenie i w przegladarce mam dostep do servera pod adresem localhost:10000, z konsoli tez mam dostep do bazy danych .....

EDIT

zmienilem host na localhost (tak jak w workbenchu) zmienil sie tylko komunikat
Cytat
[2002] No such file or directory


Ten post edytował virgus66 7.12.2017, 17:46:34
Go to the top of the page
+Quote Post
Pyton_000
post 7.12.2017, 17:50:02
Post #8





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


No to skoro łączysz się na porcie 10000 to czemu podajesz 3306??
Go to the top of the page
+Quote Post
virgus66
post 7.12.2017, 17:54:17
Post #9





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 7.12.2017

Ostrzeżenie: (0%)
-----


3306 to domyslny port dla databasy, jego uzywam w polaczeniu MySQL workbencha. 10000 to port do glownego serwera
Go to the top of the page
+Quote Post
Pyton_000
post 7.12.2017, 18:02:31
Post #10





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


to gdzie ty się chcesz połączyć w końcu? do lokalnej bazy czy zdalnej?
Go to the top of the page
+Quote Post
virgus66
post 7.12.2017, 18:04:41
Post #11





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 7.12.2017

Ostrzeżenie: (0%)
-----


do zdalnej, w workbenchu uzywam portu 3306 i sie lacze z baza danych. Juz kompletnie nie rozumiem tego, tu dziala tam nie
Go to the top of the page
+Quote Post
Pyton_000
post 7.12.2017, 18:13:56
Post #12





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


pokaż screena
Go to the top of the page
+Quote Post
virgus66
post 7.12.2017, 18:19:25
Post #13





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 7.12.2017

Ostrzeżenie: (0%)
-----


https://ibb.co/kGsrsw



a tu polaczenie z konsoli, jak widzisz w pasku dziala na porcie 10000

https://ibb.co/h1uhzb

Ten post edytował virgus66 7.12.2017, 18:24:05
Go to the top of the page
+Quote Post
Pyton_000
post 7.12.2017, 18:37:35
Post #14





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


odpal sobie tunel:

ssh -L3307:127.0.0.1:3306 ucado-dev@app.ucado.co.uk -N

i połączenie w PDO na

mysql:host=127.0.0.1;port=3307
Go to the top of the page
+Quote Post
virgus66
post 8.12.2017, 11:45:49
Post #15





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 7.12.2017

Ostrzeżenie: (0%)
-----


tunel odpalony, port w pdo zmieniony na 3307 - teraz komunikat zmienil sie na connection refused ..... i niewiele to mowi, nie wiadomo dlaczego odrzuca

Cytat
ERROR - Connection to DB failed: SQLSTATE[HY000] [2002] Connection refused


czy mozliwe ze teraz w php.ini albo pliku mysql.ini cos trzeba zmienic w portach? moze domyslnie chce dostepu przez 3306 ?

Ten post edytował virgus66 8.12.2017, 11:54:35
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.03.2024 - 19:23