Thread: Change user

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    44
    Rep Power
    2

    Change user


    Searched google and the forum, haven't found a solution yet.

    How to I logon to the MySQL console as a newly created user?

    As soon as I open the console I'm asked to provide a password (for root). After logging in I try to switch users with -u username -p; but that doesn't work, it just errors out (ERROR 1064 (42000)). I've also gone into wampmanager.ini and changed the root user to the newly created username under [mysqlMenu] (tried this with services on and services off), still nothing.

    What's going on here?
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,191
    Rep Power
    9398
    -u username -p

    Error 1064 is a syntax error in a SQL query. You shouldn't be getting that when connecting.
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    you cannot switch users after you've connected. And of course you cannot enter console commands into the MySQL prompt, because those are no SQL queries (hence the error).

    You have to connect as that user:

    Code:
    command line prompt > mysql -u youruser -p
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    44
    Rep Power
    2
    so I can only use a different user from the cmd prompt and not the SQL prompt?
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Originally Posted by solosheff
    so I can only use a different user from the cmd prompt and not the SQL prompt?
    True. Why would you wanna switch users in between, anyway? I can hardly think of a good reason to do that.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  10. #6
  11. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Whoops, I thought that spammer was the first post in the thread, so I deleted and then restored it. Your subscriptions may have broken.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    44
    Rep Power
    2
    not that I wanted to switch back and fourth between users, I just didn't know you could only use the SQL prompt as root. I was told (via lynda.com) that it was a good security practice to create a new user with limited permissions. I thought I could use that user with the SQL prompt.
  14. #8
  15. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    ??

    You can and you should connect as a different user than root. That's what I just said.

    But you have to specify that user when you connect. Like this, for example:

    Code:
    /usr/bin/mysql -u youruser -p
    What you cannot do is connect as root and then switch users afterwards. You have to specify the right user from the beginning.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    44
    Rep Power
    2
    Originally Posted by Jacques1
    ??

    You can and you should connect as a different user than root. That's what I just said.

    But you have to specify that user when you connect.
    I'm not having a problem choosing a user from the cmd prompt, and if that's the only prompt I should be using, than consider this case closed.

    But, if you're telling me that I should be using the MySQL prompt as a user other than root, then this is where my problem comes in...

    As soon as I open up the MySQL prompt, "Enter Password:" is the first thing I see. I don't have a choice in which user I want to log in as. I mentioned this in my initial post, I may have been unclear, sorry.
  18. #10
  19. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,191
    Rep Power
    9398
    You choose the user when you run the console app. On the command line when you're typing the name of the program. MySQL will not prompt you to pick a user, you have to tell it the one you want.

    That "-u username -p" stuff is what you enter at that time. You don't try to run it after you've connected. You type very nearly literally
    Code:
    mysql -u username -p
    Normally you might just run "mysql" or "mysql -p". In fact I know you must be doing the latter because you're getting the password prompt.

    Great, that -p you used was a command line option. Now also give it the option "-u username".

    Not sure how many other ways we can put this...

IMN logo majestic logo threadwatch logo seochat tools logo