Giter Site home page Giter Site logo

Connection options about mysqldump-php HOT 6 CLOSED

ifsnop avatar ifsnop commented on May 8, 2024
Connection options

from mysqldump-php.

Comments (6)

ifsnop avatar ifsnop commented on May 8, 2024

tl;dr Not yet, give me a couple of days to thing best way to do it.

Although the link you provide doesn't work, I get the idea. The --protocol option is only useful to force a different type of connection, for example, connecting to localhost by default makes the connection using a socket. If you want to connect using tcp, you then use --protocol=TCP.

Please see:
http://php.net/manual/en/ref.pdo-mysql.connection.php

When the host name is set to "localhost", then the connection to the server is made thru a domain socket.

mysqldmp-php passes the host option directly to the dsn option of the constructor.

https://github.com/ifsnop/mysqldump-php/blob/master/src/Ifsnop/Mysqldump/Mysqldump.php#L194

Unfortunately, there is no way to connect using a socket different from the default one with the current mysqldump-php code.

Changes needed to support connecting through a socket would probably made the next version of mysqldump-php incompatible with the current one. Last option is currently not supported.

mysql:host=localhost;dbname=testdb
mysql:host=localhost;port=3307;dbname=testdb
mysql:unix_socket=/tmp/mysql.sock;dbname=testdb

from mysqldump-php.

pdewouters avatar pdewouters commented on May 8, 2024

Ah, you're right - it was working when I posted. Anyway, the use case would be when the hostname is followed by a custom path : localhost:/tmp/mysql5, so yes like in your example :)

Right now, we're just parsing the host parameter for a : and use the part after it for the socket
https://github.com/humanmade/backupwordpress/blob/master/classes/class-backup.php#L805

Adds socket parameter to mysqldump
https://github.com/humanmade/backupwordpress/blob/master/classes/class-backup.php#L866

from mysqldump-php.

ifsnop avatar ifsnop commented on May 8, 2024

Looks like using a DSN string is the best way to handle connection strings to databases. In the end, PDO will take care of it without parsing.

from mysqldump-php.

pdewouters avatar pdewouters commented on May 8, 2024

makes sense

from mysqldump-php.

ifsnop avatar ifsnop commented on May 8, 2024

Please, take a look at the devel branch.

from mysqldump-php.

ifsnop avatar ifsnop commented on May 8, 2024

Everything should be fixed by now.

I will bump version to 2.0 because now the constructor takes a dsn string as a parameter, the same that is needed by PDO to create the connection, and everything is parsed from there. Also now the default filename name equals to stdout, to mimic mysqldump behavoiur.

I rewrote some parts of old code, but didn't tag it yet to 2.0. If more positive comments are made, I will be very happy to improve things.

from mysqldump-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.