Jump to content



Photo

Mysql Monitor (Odbc@Localhost)


  • Please log in to reply
10 replies to this topic

#1 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 5 August 2011 - 1:37 PM

I've been experiencing some kind of bug with the MySQL monitor. I'm using Zend Community Server on Windows 7. PHP 5.35, MySQL 5.1.50.

It seems that when I open the MySQL monitor, sign in as root, then pin the icon to my taskbar, if I ever exit the MySQL program with the exit command, when I click the taskbar icon again to open it, I'm still signed in, but as "odbc@localhost" and lose access to my databases. There's no way to sign out from this, either.

Has anyone experienced this or know why it happens? I usually use PHPMyAdmin, but I'm learning to type all my commands in as well.
  • 0

#2 Larry

Larry

    Administrator/Writer

  • Administrators
  • 3,808 posts
  • LocationState College, PA (USA)

Posted 5 August 2011 - 2:07 PM

I don't regularly use Windows, so I've never pinned the MySQL monitor to the taskbar (I don't really know what that means), so I couldn't speak to this. Sounds like it may be a bug in the Zend Community Server.
  • 0

#3 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 5 August 2011 - 2:25 PM

Pinning the icon to the taskbar just means that the icon to start the program is always there at the bottom of the desktop instead of going through Start/Programs.

Another question... how do I login as a different user with the MySQL monitor? When I start it up, I can only enter the root password. I've set up the root user and the louis user through phpmyadmin. the louis user can only insert, update, select, and delete. i'd like to sign in as this user through mysql monitor, but don't see how to do it. using commands like -u louis -p -h localhost; does nothing. I'm completely confused. Do I have to change directories as it mentions in your book? I don't think so, because the top of the mysql monitor says it's already in the properl directory that mysql.exe is located.
  • 0

#4 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 5 August 2011 - 3:42 PM

the command:
mysql -u username -p -h hostname

never works. i always get a syntax error at the mysql monitor screen. why? say i have a user larry with password ullman on localhost

at the mysql>

mysql -u larry -p -h localhost;

i get a syntax error 1064 (42000)... i'm at my wits end :) i don't get access denied... i get a syntax error!
  • 0

#5 Paul Swanson

Paul Swanson

    Excellent Advisor

  • Members
  • PipPipPip
  • 163 posts
  • LocationPortland, OR, USA

Posted 5 August 2011 - 4:38 PM

Try:
mysql -u larry -p
The host name is optional. Are you getting prompted for the password?

And what is the full error? MySQL generally tries to tell you approximately where in your statement it is detecting an error.
  • 0

#6 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 5 August 2011 - 4:53 PM

Try:

mysql -u larry -p
The host name is optional. Are you getting prompted for the password?

And what is the full error? MySQL generally tries to tell you approximately where in your statement it is detecting an error.


still doesn't work. says:

you have an error in your sql syntax... check the manual near 'mysql -u larry -p' at line 1. no matter what i do, i get this error. i created another user in phpmyadmin that has select, insert, update, and delete privileges on a certain database, say... larry.

in the mysql monitor, before i try to change the user to larry, i make sure to show databases, and then use the larry database.

any attempt to then change the user to the one i created results in this syntax error in the mysql monitor.
  • 0

#7 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 5 August 2011 - 4:56 PM

I have also updated my pdoconnect file to use the larry user that has select, update, delete, insert privileges on the larry database, and my localhost website still works (no access denied error). i can see this user when using phpmyadmin. larry/localhost. so what's up with my mysql monitor?
  • 0

#8 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 5 August 2011 - 5:28 PM

I can get in and change the user if I use cmd on windows 7. I can sign in as root, larry, basic, all of my users.

However when I use the mysql command line client (start/all programs/zend server/mysql server 5.1/command line client) I simply cannot change users and it logs me in as root automatically, and when i enter the SQL to change the user, I get a syntax error.

It seems that the mysql command line logs me in as root, and there's no way i can change users because i can't get back to the bin directory. When I use CMD, when i enter exit i am taken back to bin, where i can change users to root or one of the basic users i created....

anyone have any ideas?
  • 0

#9 Paul Swanson

Paul Swanson

    Excellent Advisor

  • Members
  • PipPipPip
  • 163 posts
  • LocationPortland, OR, USA

Posted 5 August 2011 - 5:54 PM

I don't think you can change the user with an SQL query, you have to start the client as a particular user. mysql -u larry -p isn't SQL, it's a command followed by arguments that are passed to the client application. If you want to start the client as a different user, you need to use Start > Run > cmd and then sign in.

In PHP (or ASP, etc.) you will use functions to connect to the database as a specific user, passing the username, password, hostname and database name. You don't access the client the same way as you would if you were running it from a command line. I have the first edition of the book, and chapters 6, 7 and 8 describe how to connect using different scripting languages. I think you are making this harder than it is. To do admin stuff, I always use phpMyAdmin locally, or I use the Linux command line to start the client on our server (because we don't have phpMyAdmin installed there).
  • 0

#10 Lou

Lou

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 5 August 2011 - 6:03 PM

thanks Paul... I've been using PHPMyAdmin for about a year, but to learn SQL better, I've been trying to use the command line for many things. I'm actually connecting MySQL through PDO (upgraded from mysqli procedural) but I just couldn't figure out what was going on in the command line client.

When you put it the way you did, that -u username is not SQL, it makes perfect sense. I was just assuming that the command line client would work the same way as all the examples in Larry's 2nd edition, and the 5 other MySQL books I have.

This leads me to another question. When you start the command line client, how do you start it with another user other than root, or is that not possible?

Thanks very much for your clear explanation previously!
  • 0

#11 Paul Swanson

Paul Swanson

    Excellent Advisor

  • Members
  • PipPipPip
  • 163 posts
  • LocationPortland, OR, USA

Posted 8 August 2011 - 10:34 AM

Sorry I didn't reply earlier. I had a busy weekend.

To start MySQL with any user you need to be at a command line in the folder where the MySQL executable resides (on my Windows XP computer with WAMP installed, it is at C:\Program Files\wamp\mysql\bin). You then just enter the command the way you have been trying:

mysql -u username -p

You should then get prompted to enter the password. Once you've logged in, your prompt should change to:

mysql>

And at that point you can enter SQL. You should start by selecting the database with:

USE databaseName;

Now you can enter queries at the command line.
  • 0