FAQ
I'm trying to specify a host name and database name to do an update to a
table. I can't quite figure out what the correct syntax is? Is it something
like:



USE databasename@hostname? I have tried several permutations of that but
can't quite seem to get the syntax just right.



Thanks.



-Brian

Search Discussions

  • V. M. Brasseur at Sep 2, 2004 at 10:04 pm
    Are you using the mysql client to connect? If so, you can use the -h
    and -D flags:
    mysql -h hostname [-u username -p -P port] -D databasename

    The -D flag isn't even necessary. The command above is equivalent to
    this one:
    mysql -h hostname [-u username -p -P port] databasename

    http://dev.mysql.com/doc/mysql/en/mysql.html

    If you're writing your own client, you chould check the API
    documentation for the language you're using.

    If you're using a completely different client, check the docs for it.

    Be one with your manual. Or be one with your many manuals. I leave it
    to you to figure out that existential math.

    Cheers,

    --V

    Brian Menke wrote:
    I'm trying to specify a host name and database name to do an update to a
    table. I can't quite figure out what the correct syntax is? Is it something
    like:



    USE databasename@hostname? I have tried several permutations of that but
    can't quite seem to get the syntax just right.



    Thanks.



    -Brian
  • Brian Menke at Sep 3, 2004 at 1:56 am
    Thank you for your replies. I should have been more specific. I was just
    using the sql editor in MySQL Control Center. I have two databases that I'm
    managing that sit on different physical machines, but have the same database
    names and table names etc., basically a test environment and a production
    environment. When I update one table on one machine, the other table of the
    same name on the other machine also gets updated. I swear it happened even
    though I intentionally disconnected from the other database. The same thing
    happened when I used MySQL Front. It's very bizarre.

    -Brian

    -----Original Message-----
    From: V. M. Brasseur
    Sent: Thursday, September 02, 2004 3:00 PM
    To: Brian Menke
    Cc: mysql@lists.mysql.com
    Subject: Re: How to use "use" for a specific host

    Are you using the mysql client to connect? If so, you can use the -h
    and -D flags:
    mysql -h hostname [-u username -p -P port] -D databasename

    The -D flag isn't even necessary. The command above is equivalent to
    this one:
    mysql -h hostname [-u username -p -P port] databasename

    http://dev.mysql.com/doc/mysql/en/mysql.html

    If you're writing your own client, you chould check the API
    documentation for the language you're using.

    If you're using a completely different client, check the docs for it.

    Be one with your manual. Or be one with your many manuals. I leave it
    to you to figure out that existential math.

    Cheers,

    --V

    Brian Menke wrote:
    I'm trying to specify a host name and database name to do an update to a
    table. I can't quite figure out what the correct syntax is? Is it something
    like:



    USE databasename@hostname? I have tried several permutations of that but
    can't quite seem to get the syntax just right.



    Thanks.



    -Brian
  • Roger Baklund at Sep 2, 2004 at 10:19 pm
    * Brian Menke
    I'm trying to specify a host name and database name to do an update to a
    table. I can't quite figure out what the correct syntax is? Is it
    something
    like:

    USE databasename@hostname? I have tried several permutations of that but
    can't quite seem to get the syntax just right.
    The hostname is used when connecting to the host, not when you change active
    database (with the USE statement).

    The syntax for USE is simply:

    mysql> USE databasename

    What server you connect to is defined in the connect statement of whatever
    programming language you use, or on the command line if you use the standard
    mysql client. Using the standard client it is however possible to change to
    a different server, using the 'connect' client command, short '\r'. You can
    swap to a different database on a different server using the syntax:

    mysql> CONNECT databasename otherhost

    A shortcut is defined, as mentioned. This will also work:

    mysql> \rdatabasename otherhost

    <URL: http://dev.mysql.com/doc/mysql/en/USE.html >
    <URL: http://dev.mysql.com/doc/mysql/en/mysql_Commands.html >

    --
    Roger
  • Roger Baklund at Sep 3, 2004 at 12:25 pm
    * Brian Menke
    [...]
    When I update one table on one machine, the other table of the
    same name on the other machine also gets updated.
    Sounds like replication... are you sure the machines are not set up as
    master/slave?

    --
    Roger

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmysql @
categoriesmysql
postedSep 2, '04 at 9:49p
activeSep 3, '04 at 12:25p
posts5
users3
websitemysql.com
irc#mysql

People

Translate

site design / logo © 2021 Grokbase