How do you test MySQL credentials from the command line on a Linux server?
Mysql – Test MySQL credentials from Linux command line
command linelinuxMySQL
Related Question
- Db2 – command line tool on linux to convert oracle sql into db2 sql
- Linux – Command to Kill All MySQL Sessions from a Specific User
- Mysql – Creating a database with only MySQL command line
- Mysql – Passing passwords more securely to thesql utilities on the command line
- oracle – Using SQLPlus Command Line In-line Set Commands
- MySQL – Missing Commands in Command Line History
Best Answer
@Phil's Answer and @Mr.Brownstone's Answer should suffice for your question, so +1 for both of them.
For the following, let's assume you are logging in with username
myuser
Once you have connected to mysql, you should run the following query:
Sometimes, they are different. This may give you insight into why you are allowed to login to mysql.
Here is another query you need to run:
This will show you the ways in which you are allowed to login as
myuser
.If you see
'myuser'@'localhost'
, then you can authenticate from within the DB Server.If you see
'myuser'@'127.0.0.1'
and do not see'myuser'@'localhost'
, then you can authenticate from within the DB Server again but you must specify the--protocol=tcp
from the command line.If you see
'myuser'@'%'
, then you can do remote logins from any server.If you see
'myuse'r@'10.20.30,%'
, then you can do remote logins only the from 10.20.30.% netblock.Once you see what 'mysql.user' has for your user, you may want to allow or restrict myuser from logggin in one way and not the other.
If you simply want to check if the password for
myuser
iswhateverpassword
, you can do the following:You can check from the command line as follows:
If you are not
root
and want to test myuser only, you can do this:If you get 1, password for myuser is verified as good.