Archive for the tag 'mySQL'

How to re-enable the grant table with mysql

root@dell:~# mysqladmin flush-privileges -uroot -p

When you create accounts with INSERT, it is necessary to use FLUSH PRIVILEGES to tell the server to reload the grant tables. Otherwise, the changes go unnoticed until you restart the server. With CREATE USER, FLUSH PRIVILEGES is unnecessary.

As usual when you modify the grant tables directly, you must tell the server to reload them with FLUSH PRIVILEGES so that the privilege changes take effect.

SBDavid

Checking mysql extended-status

Checking mysql extended-status

mysqladmin is a client for performing administrative operations. You can use it to check the server’s configuration and current status, to create and drop databases, and more.

root@dell:~# mysqladmin status -uroot -p
Enter password:
Uptime: 197 Threads: 1 Questions: 135 Slow queries: 0 Opens: 40 Flush tables: 1 Open tables: 34 Queries per second avg: 0.685

For Extended Status

root@dell:~# mysqladmin extended-status -uroot -p
SBDavid

Setting up the Tunnel for MySql

Setting up the Tunnel

The most common methods of setting up a tunnel are through putty or through command-line SSH.

To open an SSH tunnel via the command line, run:

ssh -L3307:127.0.0.1:3306 -p 22 -N -t -x user@myhost.com

Connecting with MySQL

You can connect to the MySQL server!
You want to choose 3307 for your local port so that it does not conflict with your existing local copy of MySQL.

mysql -u username -ppassword -h 127.0.0.1 -P 3307

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

rsync to backup your home directory and mysql databases.

Run the below rsync command using “nohup”, nohup runs a command immune to hangups, with output to a non-tty.

Rsync your home directory’s to your backup server.

Replace $IP with the IP address for your production server.

Run the below commands from your backup server.

#rsync -vrplogDtH –exclude=virtfs/ –progress -e ssh root@$IP:/home/ /home/

rsync all mysql databases.

#rsync -vrplogDtH –progress -e ssh root@$IP:/var/lib/mysql/ /var/lib/mysql/

Backup DB server_support

rsync -vrplogDtH –progress -e ssh root@$IP:/var/lib/mysql/server_support /var/lib/mysql/

« Prev - Next »