Category Archives: MYSQL

Your web site should be built around your "vision" and your "business requirements"

MySql Backup Database with mysqldump

To backup MySql Database from command line.

mysqldump -u user_name -p Database_Name > backup-file.sql

In windows xp, 7, or 8 simply run the above command in CMD. It will place the backup-file.sql in the same direcotry where you run the command from.

for more information look at mysqldump

MySql view database list, switch database and list tables

If you are running MySql form command line and you like to see list of all the database then simply run this command after login to the mysql

show databases;

this command will list all the database that are on MySql server.

If you like to work with one of the database then you can select the database with.

use database_name;

Once in the Database you like to see the list of the table use.

show tables;

This command will show the list of all the tables in that database.

Login to MySql database form command line

To login to MySql database from a commend line you can use

mysql -u root -p;

after hitting enter system will ask you for the password or you can use this command

mysql -u root -pPassword;

Once login to the database you have to select the database to work with.

MYSQL Create new user and Grant privileges

To Create a new user in mysql
CREATE USER ‘UserName’@’localhost’ IDENTIFIED BY ‘Password’;

To Grant user access to the Database
GRANT ALL PRIVILEGES ON DatabaseName . * TO ‘UserName’@’localhost’;

After that Flush the privileges so the changes will take affect.
FLUSH PRIVILEGES;