Connect to database

MyCli requires you to have a MySQL compatible server on your local computer or on a remote server reachable using TCP/IP (a SSH tunnel is commonly used for this purpose) or a UNIX domain socket (local computer only). You'll also need the right credentials (username and optionally a password).

Please note the hostname is part of the credentials for MySQL!

The following default values are used to connect:

These can be overruled by your configuration files and command line arguments (command line arguments take preference over configuration files.

The database name can be changed at runtime using the interactive command line interface (use or connect command).

It's also possible to supply some of these arguments using environment variables: * MYSQL_HOST - hostname * MYSQL_TCP_PORT - port * MYSQL_UNIX_PORT - UNIX domain socket * MYSQL_PWD - password (please note this might not be secure on some multi user systems!)

The following configuration files can be used to configure your connection:

Command line arguments

Examples

Connect using a database name: $ mycli my_database

Connect using a username, hostname and database name: $ mycli -u my_user -h my_host.com my_database

Connect using a DSN: $ mycli mysql://my_user@my_host.com:3306/my_database

Connect using a SSH tunnel:

$ ssh remote -L 3306:localhost:3306 -f sleep 60
$ mycli

Connect using a DSN alias: $ mycli --dsn server1

Sponsors

Nova Kid School

blogroll

social