Jump to content
Larry Ullman's Book Forums

Mysql Monitor (Odbc@Localhost)


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 Share

×
×
  • Create New...