Showing posts with label MYSQL. Show all posts
Showing posts with label MYSQL. Show all posts

Wednesday, 13 November 2013

Database Remote Access

Remote Access of DataBase in Different Host by use of following comment


mysql > GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY ‘PASSWORD’;

Example :
mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY ‘root’;

above command gives access for all privileges. we can grand specific privilege also.


1. Select permission

mysql> GRANT SELECT ON *.* TO 'USERNAME'@'%' IDENTIFIED BY ‘PASSWORD’;

2. Select and update permission

mysql> GRANT SELECT,UPDATE ON *.* TO 'USERNAME'@'%'  IDENTIFIED BY ‘PASSWORD’;


Monday, 28 October 2013

Recover error : 1005 Can't create table 'tmp_db' (errno: 13)

While Altering table or changing Storage Engine of Database we may be got this error.
It happens probably due to Permission denied by MySQL.

less /etc/group
and then less /etc/passwd
find mysql user and group name, probably both are named mysql

change to mysql dir, probably var/lib/mysql and then type cd .. to go a dir under.

chown -R mysql:mysql ./mysql/

And also change permission of /tmp file 


By default the temporary file are directed to /tmp partition.
The permission in /tmp is different.

$ ls -ltrh /tmp
drwxr-xr-x  4 root root      4096 Jan 24 04:02 tmp


The group has no write permission on /tmp folder.

Fix :

Changed the permission of the /tmp folder and made the installation again

chmod 777 /tmp/

$ ls -ltrh /tmp

drwxrwxrwx  4 root root      4096 Jan 24 04:02 tmp


Recover Table Crash in Mysql (MYISAM ENGINE) (Got error 134 from storage engine)

Some time you can't repair table using repair command.It will show error like  "Can’t create new tempfile: ‘*.TMD file" .So we have to recover that table particular table or all tables of database.

For that you have to use the following command to do:

First go to the library file path of Mysql


/var/lib/mysql/Particular_db_name:

1.For single table recover

            myisamchk -r -f  TABLENAME.MYI
2.For ALL table recove

            myisamchk -r -f  *.MYI





Repair Table in Mysql

You will get error like Db_Name.Table_Name marked as crashed  while exporting dump to Mysql.
For that you have to manually repair table use of following command

REPAIR TABLE TABLE_NAME

Tuesday, 21 August 2012

Recover Mysqldump Got Errno 28 On Write

     While taking Mysqldump you may got error like Backup Failed in Mysqldump Got Errno 28 On Write.
     Because of inadequate disk space to store your output file. For that you have to free up some disk space.That's all now error willl gone and working fine

Thursday, 12 July 2012

Ignore tables in MySQLdump

While taking mysqldump  some time error coming like databaseName.tableName crossed.meanwhile time you have to exclude that tables.And you don't want to include  some tables while taking mysqldump.


For that we can use    "--ignore-table=DbName.TableName" infront of  DbName in mysqldump command.see below dump command

mysqldump -ruserName -ppassWord  ----ignore-table=DbName.TableName DbName > DbName.sql

This command exclude which table you need to omit.

You can exclude multiple table also

mysqldump -ruserName -ppassWord --ignore-table=DbName.TableName1 --ignore-table=DbName.TableName2 > database.sql

Example:

mysqldump -rroot -proot  ----ignore-table=TEST.TEST_DATA TEST > TEST.sql



Monday, 11 June 2012

Fixing problem of MySQL server has gone away in Windows

While doing some operations like import files in MySQL error coming like "MySQL server has gone away".It is same PacketTooBigException in Linux.For that you have to execute the following Query in MySQL
                    "set global max_allowed_packet=16777216"
after executing this query do your operation.Error will not occur.

Tuesday, 15 May 2012

Resolving PacketTooBigException in MYSQL

Sometime if you use MySql you  may get the following error when,Installing and migration of your project.that error like  com.mysql.jdbc.PacketTooBigException:Packet for query is too large (4739923 > 1048576).
 For that you have to excute the following Query in MySql


                    set global max_allowed_packet=1817776

ReStore MYSQL Dump in Linux

ReStoring  MySql dump use of the following command

mysql -u[UserName] -p[Password] dbName < /<directory of file saved>/filename.sql

MYSQL Dump in linux

You can take MYSQL Dump using the following command

mysqldump  -u[UserName] -p[Password] dbName > /<directory to save>/filename.sql

Taking multiple databases dump at the same time

mysqldump  -u[UserName] -p[Password] [dbName1] [dbName2] ... > /<directory to save>/filename.sql

Taking dump of  Particular table in databases

mysqldump  -u[UserName] -p[Password] [dbName] [table_Name] > /<directory to save>/filename.sql

Takinge dump of  all databases

mysqldump  -u[UserName] -p[Password] -all-databases > /<directory to save>/filename.sql