Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

MySQL remote access

[es] :: PHP :: MySQL remote access

[ Pregleda: 2067 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

mega023
NS

Član broj: 25570
Poruke: 100
82.117.202.*

ICQ: 27429884
Sajt: www.svetautomobila.com


Profil

icon MySQL remote access21.02.2005. u 22:10 - pre 232 meseci
Imam vise servera i zelim da mi baza bude samo na 1 a da se ostali "kace" na taj jedan i da je koriste....

Ima li neko resenje koje radi i na sta treba da obratim paznju?
 
Odgovor na temu

mega023
NS

Član broj: 25570
Poruke: 100
82.117.202.*

ICQ: 27429884
Sajt: www.svetautomobila.com


Profil

icon Re: MySQL remote access21.02.2005. u 22:25 - pre 232 meseci
NASAO SAM ODGOVOR

I was trying for the first time to login the database from a remote location, and i got the following error:

mysql -u testuser -h 111.111.111.111 -p
Enter password: xxxxxxxx
ERROR 1045 (28000): Access denied for user 'testuser'@'user-0cdfi7k.cable.mindspring.com' (using password: YES)
[dual-g5:~] marcvano%

The solution was to setup for that user 'testuser' privileges with the "grant" command first for that particual domainname (hostname) on the server.

Because i wanted to login from any place in the world:

i did it with following command:

grant all on * to 'usertest'@'%' identified by 'mypassword';

the @'%' means any domainname.


Novo Pitanje
Da li je bolje da koristim mysql_connect ili mysql_pconnect ?

 
Odgovor na temu

MileG

Član broj: 28981
Poruke: 997



+7 Profil

icon Re: MySQL remote access21.02.2005. u 23:04 - pre 232 meseci
Odgovor, koliko ja znam, glasi...
Funkcija mysql_connect() pravi konekciju i ostavlja je otvorenu dok je ne zatvoris sa mysql_close().
Funkcija mysql_pconnect() koristi vec otvorenu konekciju ukoliko postoji a ako je nema otvara je i zavrsetkom rada sa bazom zatvara je automatski.
Znaci, valjda razumijes:

mysql_connect()
...
mysql_close()

mysql_pconnect()
...

Mislim da drugih razlika izmedju ove 2 funkcije nema ili bar nisu velike. U svakom slucaju pogledaj manual i koristi google sigurno ces naci bolji odgovor na bilo kojem od ova 2 navedena mjesta :o)

Reference for: mysql_pconnect
Two major differences between mysql_connect() and mysql_pconnect() are:

First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use ( mysql_close() will not close links established by mysql_pconnect() ).

http://www.php.net/manual/en/function.mysql-pconnect.php

Sta je bolje sam prosudi... :o)
 
Odgovor na temu

Goran Rakić
Beograd

Moderator
Član broj: 999
Poruke: 3766

Sajt: blog.goranrakic.com


+125 Profil

icon Re: MySQL remote access26.02.2005. u 14:21 - pre 232 meseci
Napomena: Umesto % (all) dodaj posebne korisnike za svaki host posebno. Dodatno, mozes svakom ograniciti samo one privilegije koje mu trebaju.

Druga napomena:
Citat:

I read all of the time that people are not sure when to use mysql_connect or mysql_pconnect. Here is the law. First check your my.cnf file, which is usually in /etc/my.cnf and look for wait_timeout and see how many seconds it is set for. If it's not in your my.cnf file, you can assume it's at the default which is 28800 or 8 hours. This means that if you use mysql_pconnect, you will have one apache process connected to mysql for 8 hours. So with this information, you can benchmark with a program like Xdebug and see the difference in speed for one mysql_connect versus one mysql_pconnect. Then run it again and you will see that the mysql_pconnect will connect the second time in about .00043 seconds, versuses the mysql_connect at .02072 seconds. Now we are talking milliseconds at this point, but trust me every millisecond counts in the long run. So my rule of thumb for using persistent database connections with any of my PHP scripts is this, if you plan on getting more than 2 visitors per hour, use mysql_pconnect. If you don't plan on getting more than 2 hits per hour, why are you wasting your time?


Medjutim pconnect ima i mane pocev od toga da treba voditi racuna sa brojem konekcija (lako se moze dogoditi da kada jednom pokrenete skriptu ne mozete se narednih 8 sati konektovati na MySQL server).

Citat:

Be careful using mysql_pconnect. If you are hosting on an ISP, they may frown upon you using multiple persistant mysql connections as this consumes resources for a longer period of time. If your script crashes, your connection can stay open for long periods of time. If there is a loop involved, you could accidently eat up all the available connections. That might be considered abuse by an ISP and you could get in trouble. Try using mysql_connect first instead. 90% of the time, a non-persistant mysql_connect call will do the trick just fine.


Takodje kada se koristi mysql_pconnect ne smeju se koristiti transakcije (InnoDB) niti bilo koje zakljucavanje tabela jer moze doci do cudnih problema.

Citat:

In general use mysql_connect() for connecting to MySQL unless that connection takes a long time to establish.


naravo, u komentarima php dokumentacije mogu se naci i korisne primene poput multi-page transakcije sa kojima se svi susrecemo i pravimo raznorazne fazone sa tmp unosima u neke privremene tabele i slicnim stvarima.

Na kraju, pconnect razlikuje dve konekcije na osnovu hash-a od host-a user-a i pass-a tako da i o tome treba voditi racuna.

Ja sam do sada samo par puta morao koristiti pconnect, za ostale stvari koristim regularan mysql_connect.

Pogledati: http://www.php.net/manual/en/features.persistent-connections.php
http://sr.libreoffice.org — slobodan kancelarijski paket, obrada teksta, tablice,
prezentacije, legalno bez troškova licenciranja
 
Odgovor na temu

[es] :: PHP :: MySQL remote access

[ Pregleda: 2067 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.