Connect or and Disconnect MySql Server From Client - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Random Posts

Connect or and Disconnect MySql Server From Client

Share This

After installing MySQL server software on a machine, if you want to access MySQL using a command-line utility, you have to create a connection to the server following the steps discussed below.


To connect to the server, you need to provide a user name and a password. The password is required only if the password has been set at the time of installation.

If MySQL is installed on the local machine, where you are logged in, you may try the following command on the command prompt.

shell> mysql -u user -p
Enter password: ********


When you are logged in to a system and you want to access MySQL which is installed in a different system, you have to mention the hostname or IP address of the MySQL server. Hence, you may try the following command.

shell> mysql -h host -u user -p
Enter password: ********


Here, the host represents the domain name or IP address of the server where your MySQL is running and the user represents the MySQL user account.

If the MySQL user account is configured using a password, you have to enter the password when you will be prompted to enter it.



If you are logged in to the server successfully, you should see the following introductory message on the terminal and you should get mysql> prompt.

shell> mysql -h host -u user -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 25338 to server version: 5.1.21-beta-standard
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql>

This prompt indicates that the mysql server is connected and is ready to accept commands.



Sometimes, MySQL installations allow anonymous users to connect to the local system. In this case, you should be able to connect to the server by entering mysql without any options as shown below.

shell> mysql
After completing your task, if you want to be disconnected from the MySQL server, you have to type QUIT (or \q) at the mysql> prompt:

mysql> QUIT
Bye

On Unix, you can also disconnect by pressing Control-D.


I Hope, you now understand how to Connect or Disconnect the MySQL server from the client


Happy Exploring!

No comments:

Post a Comment