June 18th, 2013, 10:23 AM
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?
June 18th, 2013, 12:37 PM
-u username -p
Error 1064 is a syntax error in a SQL query. You shouldn't be getting that when connecting.
June 18th, 2013, 12:51 PM
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:
command line prompt > mysql -u youruser -p
June 18th, 2013, 01:23 PM
so I can only use a different user from the cmd prompt and not the SQL prompt?
June 18th, 2013, 02:33 PM
True. Why would you wanna switch users in between, anyway? I can hardly think of a good reason to do that.
Originally Posted by solosheff
June 18th, 2013, 02:36 PM
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.
June 18th, 2013, 02:48 PM
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.
June 18th, 2013, 03:01 PM
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:
What you cannot do is connect as root and then switch users afterwards. You have to specify the right user from the beginning.
/usr/bin/mysql -u youruser -p
June 18th, 2013, 03:57 PM
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.
Originally Posted by Jacques1
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.
June 18th, 2013, 04:00 PM
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
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.
mysql -u username -p
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...