mysql Putty Commands

Log onto mysql:
mysql -p
mysql -u root -p
Create a database:
mysql> create database [database name];
Show all databases:
mysql> show databases;
Select database:
mysql> use [database name]
Show your database tables:
mysql> show tables;
Find database directory:
mysql> select @@datadir;
Create user:
mysql> grant all privileges on [database name].* to ‘[username]’@’localhost’ identified by “[password]”; mysql> select * from mysql.user; mysql> select host, user, password from mysql.user;
Dump a sql database file:
mysql> quit (quit out of mysql)
$ mysqldump -u[username] -p[password] [database name] > [location of sql database]

Dump all databases:
$ mysqldump -u root – –all-databases > [location of sql database]
Restoring a sql database file:
$ mysql -u[username] -p[password] [database name] < [location of sql database]

Things to keep in mind:
If moving or deleting things do not work, don't forget to use "sudo"
to see list of files and folder in directory.

Leave a Comment

5 + twenty =