seantrant
8/17/2016 - 9:33 AM

SQL Commands + SSH

SQL Commands + SSH

To login to server with port append -p (port number)
eg. ssh root@vbb -p 2222

To access mysql through ssh:   
use the db user and password dummy!
not the ssh root user, you do need to be logged in as root thought so "su root"
mysql -u (username) -p (db name)
eg.  mysql -u root -p password

to show tables: mysql> show tables;

to alter table name: mysql> ALTER TABLE commIssue RENAME commissue;

to add columns: mysql> ALTER TABLE  `name` ADD COLUMN `whateverworker` VARCHAR( 50 ) NULL;

To import existing table run this command from the directory that the .sql file is in
mysql -p -u (user) (dbname) < filename.sql
eg. mysql> mysql -p -u root password < whatever.sql

To put a backup of databse in current directory
mysqldump -uUSERNAME -pPASSWORD DATABASE > whatever.sql

To Drop Table
DROP TABLE table_name;