Welcome to WebmasterWorld Guest from 107.20.34.173

Forum Moderators: bakedjake

Message Too Old, No Replies

How to access mysql from ssh?

     

sodani

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

5+ Year Member



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?

Thanks!

coopster

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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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:
[dev.mysql.com...]

zCat

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

10+ Year Member



Something along the lines of:

mysql -h hostname -u user -ppassword databasename

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

sodani

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

5+ Year Member



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.

zCat

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

10+ Year Member



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

sodani

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

5+ Year Member



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.

zCat

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

10+ Year Member



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

sodani

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

5+ Year Member



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.

coopster

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

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



If I remember correctly, plesk rubs out the 'root' user in MySQL and uses a password in
/etc/psa/.psa.shadow

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

sodani

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

5+ Year Member



Cool. Thanks.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month