Archive for the tag 'Working'

SBDavid

Working with mysql databases

Creating mysql user and then setting password for user.

mysql> create user @localhost;
mysql> SET PASSWORD FOR r@localhost=PASSWORD(”);

How to set up password for mysql root user.

mysql> SET PASSWORD FOR root@localhost=PASSWORD(’);

In the below eaxmple, database and user is the same - serverbuddies

mysql> create database serverbuddies;


How to give permission to user - serverbuddies.

mysql> grant INSERT,SELECT on root.* to serverbuddies@localhost;
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on serverbuddies.* to serverbuddies@localhost;
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on serverbuddies.* to serverbuddies;

The next example has user as admin and databses as ubuntu.

mysql> create database ubuntu;

Setting permission to user admin for the database ubuntu.

mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on ubuntu.* to admin@localhost;
mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on ubuntu.* to archive;
mysql> exit


How to take mysql remote and local backup.

Doing Remote Mysql databse Backup:

`which mysqldump` -h -uusername -ppassword –opt database > /filename.sql


Local Host mysql Backup:

`which mysqldump` -uroot -ppassword –opt database > /filename.sql