views:

40

answers:

6

Is there a command line script/tool I can use to administer a mysql database. I am in a tightly controlled environment and I can not use tools like phpmyadmin and can only access my database through command line (ssh connection). I can even live with something that can get show table status and describe all tables and write that into a text file. Thanks

A: 

all you need to administrate mysql is mysql. start mysql on the command line and type the requests you want/need.

oezi
+2  A: 

The mysql command-line tool comes with the MySQL DBMS.

Ben S
A: 

Just use the mysql client (UNIX command mysql). Are you using UNIX?

greg0ire
+1  A: 
echo "USE database_name; DESCRIBE table_name;" | mysql -u user -p > outfile.txt

You can also enter the password just after the p flag without space, but remember to clear later your command history

astropanic
+1  A: 

Yes, if you install the mysql client, the tool is called mysql.

$ mysql -u root -p

Here's some commands to get you started:

use db_name; // db_name is your db

help show;

show tables;

show columns from tbl_name; // tbl_name is a table in your db

Donald
A: 

Thanks for the answers. with your help uin the end, the solution that worked for me is to create a .sql files with all the command I needed to get my reports and maintenance. I then used $>tee out.txt; command to log my output to a file and it is working great now. To cancel tee use at mysql command line $>notee;

biomed