new to mysql. 2 questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pembed2003

    new to mysql. 2 questions

    Hi All,
    I am new to mySQL and I have 2 questions:

    1. Everytime I login to mySQL:

    machine 21:06:32 ~ $ mysql -u root -p
    Enter password:

    It asks me for password. Since I didn't set a password for root when I
    installed mySQL, I can just hit Enter and I will be login. This seems
    silly so is there a way to disable the prompt so I am automatically
    login without hitting Enter?

    2. I want to create a user account with only SELECT privilege from
    everywhere (like from other hosts). How can I do that? Will the
    following work:

    GRANT SELECT PRIVILEGES ON mydb.* TO 'readonly'@'*' IDENTIFIED by
    'password'

    Do I need to create the 'readonly' user first? Or will the above
    automatically create the 'readonly' user if it does not already
    exists?

    Thanks!
  • pekka

    #2
    Re: new to mysql. 2 questions



    pembed2003 wrote:
    [color=blue]
    > Hi All,
    > I am new to mySQL and I have 2 questions:
    >
    > 1. Everytime I login to mySQL:
    >
    > machine 21:06:32 ~ $ mysql -u root -p
    > Enter password:
    >
    > It asks me for password. Since I didn't set a password for root when I
    > installed mySQL, I can just hit Enter and I will be login. This seems
    > silly so is there a way to disable the prompt so I am automatically
    > login without hitting Enter?
    >[/color]

    you can give your password also in command line, but i think you have to
    have the password set

    $ mysql --user root --password=mysql --database=dbase $*

    --
    pekka

    Outoa, kaikki älykkäät ihmiset ovat samaa mieltä kanssani.

    Comment

    • Aggro

      #3
      Re: new to mysql. 2 questions

      pembed2003 wrote:
      [color=blue]
      > machine 21:06:32 ~ $ mysql -u root -p[/color]

      Try this:
      machine 21:06:32 ~ $ mysql -u root
      [color=blue]
      > 2. I want to create a user account with only SELECT privilege from
      > everywhere (like from other hosts). How can I do that? Will the
      > following work:
      >
      > GRANT SELECT PRIVILEGES ON mydb.* TO 'readonly'@'*' IDENTIFIED by
      > 'password'[/color]

      Looks correct, except the username and address should look like this:
      'readonly'@'%'
      [color=blue]
      > Do I need to create the 'readonly' user first? Or will the above
      > automatically create the 'readonly' user if it does not already
      > exists?[/color]

      Yes, it will create the user also.

      Comment

      Working...