It is possible to specify connection parameters without entering them on the command line every time a client program is invoked. It can be done using any one of the way − mysql -port=13306 -host=127.0.0.1 To cause the port number to be used, force a TCP/IP connection. Lets see how it can be done − mysql -host= -port=13306 To specify a port number explicitly, the -port or -P option can be used. The command would connect to the server running on using the default port number (3306). MySQL command-line client program provides interaction with the database server in an interactive and non-interactive mode. (period) can also be mentioned as the host name.Ĭonnections to remote servers will use TCP/IP. This can be done by specifying the -pipe or -protocol=PIPE option. On Windows, MySQL client can be forced to use a named-pipe connection. Let us see with the example − Example mysql -host=127.0.0.1 If that is your case but you have SSH access to your server, you can create an ssh tunnel and connect through that. The transport protocol can be explicitly mentioned using the -protocol=TCP option. mysql servers are usually configured to listen only to localhost (127.0.0.1), where they are used by web applications. Instead of this, the IP address or name of the local server can also be mentioned. To ensure that the client makes a TCP/IP connection to the local server, ‘-host’ or ‘-h’ needs to be specified, with a host name value of 127.0.0.1 (instead of localhost). If the host is not specified or it is a localhost, a connection to the local host occurs Mysql -h localhost -u myname -ppassword mydbĬlient programs determine the type of connection that needs to be made − Let us see this with the command − mysql -host=localhost -user=myname -password=password mydb To select a default database, add a database-name argument. To specify the host name, user name and password specifically, provide appropriate options on the command line. Since there is no such argument, mysql selects no default database. No password is sent because neither -password nor -p has been mentioned.įor mysql, the first non-option argument is considered the name of the default database. The default user name is ODBC on Windows. ![]() Since there are no parameter options, the default values will be applied − The below command invokes mysql without specifying any explicit connection parameters − mysql This is done for clients like mysql or mysqldump. Let us understand how MySQL can be connected to the database using the command-line.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |