homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

How to access mysql from ssh?

 4:30 pm on Aug 23, 2006 (gmt 0)

Hi, I use godaddy's virtual dedicated servers and have SSH access, but they won't tell me what the command is for accessing mysql. Simply typing in "mysql" at the command line yields a 1045 error. Can anyone tell me how I can figure this out?




 4:45 pm on Aug 23, 2006 (gmt 0)

That is an "Access denied for user '%s'@'%s' (using password: %s)" message. When you invoke the command line interface (CLI) you need to specify at least the user and password, but often times the host and database as well. Try
mysql -u username -p databasename

You will be prompted for your password as that is what the
-p switch is for. You could actually type in your password directly after the switch, but that is bad practice as it is entered into the bash logs where anybody with access to the logs will find your open text password.

More info on the MySQL command line options:


 4:46 pm on Aug 23, 2006 (gmt 0)

Something along the lines of:

mysql -h hostname -u user -ppassword databasename

see e.g. [dev.mysql.com...]


 8:23 pm on Aug 23, 2006 (gmt 0)

I see. That worked. Now, that works if you're administering an existing database, but lets say that you don't have any databases on your server or that you want to create a new one. Would that be a ssh command?

Just so you know where I'm coming from, I have plesk installed on this server and so far, I've set up all my databases in plesk.

Thanks again.


 8:30 pm on Aug 23, 2006 (gmt 0)

You need to connect to MySQL as the root user (the MySQL root user, not the Linux root user) and simply "CREATE DATABASE nameofnewdatabase".


 8:37 pm on Aug 23, 2006 (gmt 0)

Oh I think I was logging in as an individual database user. Is there a way for me to figure out what the root login for mysql is through SSH? Or would I have to ask my web host? They're not very good at helping with this type of stuff.


 9:19 pm on Aug 23, 2006 (gmt 0)

You could try connecting using the Linux root user's password, if you have that - it's possible they're the same; or try connecting without a password - it's possible (horrible thought) that the root user doesn't have a password (simply use "mysql -u root").

Failing that I assume the password must be stored in the Plesk configuration somewhere if Plesk enables you to create databases. (I don't know Plesk so I've no idea where to look).


 9:29 pm on Aug 23, 2006 (gmt 0)

plesk has its own login, but it doesn't look like I can administer the mysql root login. I guess I can always just create databases along with corresponding logins in plesk and then mysql them in ssh. Oh well.

Thanks for your help.


 10:01 pm on Aug 23, 2006 (gmt 0)

If I remember correctly, plesk rubs out the 'root' user in MySQL and uses a password in

cat /etc/psa/.psa.shadow will likely show you your password (user is typically 'admin').


 9:12 pm on Aug 25, 2006 (gmt 0)

Cool. Thanks.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved