Results 1 to 2 of 2

Thread: How to Connect or Disconnect from the MYSQL Server

  1. #1
    Join Date
    Aug 2008
    Posts
    46

    How to Connect or Disconnect from the MYSQL Server

    To connect to the server, you will usually need to provide a MySQL user name when you invoke mysql and, most likely, a password. If the server runs on a machine other than the one where you log in, you will also need to specify a host name. Contact your administrator to find out what connection parameters you should use to connect (that is, what host, user name, and password to use). Once you know the proper parameters, you should be able to connect like this:

    Code:
    shell> mysql -h host -u user -p
    Enter password: ********
    host and user represent the host name where your MySQL server is running and the user name of your MySQL account. Substitute appropriate values for your setup. The ******** represents your password; enter it when mysql displays the Enter password: prompt.

    If that works, you should see some introductory information followed by a mysql> prompt:

    Code:
    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.0.78-standard
    
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    
    mysql>

  2. #2
    Join Date
    Aug 2008
    Posts
    46

    Re: How to Connect or Disconnect from a MYSQL Server

    The mysql> prompt tells you that mysql is ready for you to enter commands.

    If you are logging in on the same machine that MySQL is running on, you can omit the host, and simply use the following:

    Code:
    shell> mysql -u user -p
    If, when you attempt to log in, you get an error message such as ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2), it means that that MySQL server daemon (Unix) or service (Windows) is not running.

    Some MySQL installations allow users to connect as the anonymous (unnamed) user to the server running on the local host. If this is the case on your machine, you should be able to connect to that server by invoking mysql without any options:

    Code:
    shell> mysql
    After you have connected successfully, you can disconnect any time by typing QUIT (or \q) at the mysql> prompt:

    Code:
    mysql> QUIT
    Bye
    On Unix, you can also disconnect by pressing Control-D.

Similar Threads

  1. Yet another Server 2003 disconnect problem
    By medic1202 in forum Windows Server Help
    Replies: 4
    Last Post: 07-02-2012, 11:59 PM
  2. Replies: 3
    Last Post: 07-11-2009, 09:36 PM
  3. cannot connect to local MySQL server in Debian 4
    By Protoplasm in forum Networking & Security
    Replies: 4
    Last Post: 06-05-2009, 12:38 PM
  4. How to connect to mysql from outside
    By AmdUser in forum Software Development
    Replies: 4
    Last Post: 22-04-2009, 08:13 PM
  5. How to Connect MySQL database from PHP
    By Booth in forum Software Development
    Replies: 3
    Last Post: 21-01-2009, 09:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,123,763.29309 seconds with 17 queries