web analytics

Category Databases

ERROR 1148 (42000): The used command is not allowed with this MySQL version – LOAD DATA LOCAL INFILE

I was trying to populate a mysql database from contents inside a csv files as follows, when I got the error ūüôĀ


mysql>LOAD DATA LOCAL INFILE ‘/home/abc/public_html/test.csv’ into table test_list;
ERROR 1148 (42000): The used command is not allowed with this MySQL version

To correct it, I did the following.


1) Open my.cnf and added the line “local-infile=1”¬† under [mysqld] and [mysql]

[mysqld]
local-infile=1

[mysql]
local-infile=1

Save and quit the file.

/etc/init.d/mysql restart

2) Grant file privilege for the user

mysql> grant file on *.* to user@’localhost’;

mysql>  flush privileges;

3) Restart mysql

/etc/rc.d/init.d/mysql restart


Now try load data command again, and yes!!!!! it works ūüôā

Read More

The used command is not allowed with this MySQL version – LOAD DATA LOCAL INFILE

This error normally occurs when you run the ‘load data local infile’ command in mysql.

If you are seeing this error in shell, please check this link

If you are seeing this error while running a php script, here are the following things you can test.

I have a php script as follows for testing.


<?php
mysql_connect(“localhost”,”myuser”,”mypass”)or die(mysql_error());
mysql_select_db(“abc_test”) or die(mysql_error());

$query =”LOAD DATA LOCAL INFILE ‘/home/abc/public_html/test.csv’ INTO TABLE abctesting”;
mysql_query($query) or die(mysql_error());

?>

The file ‘test.csv’ contains some random input and if when this script runs, my database abc_test should populate the table abctesting with contents from the file ‘test.csv’

Unfotunately, when I ran this script over browser, I got the following ...

Read More

“WARNING: You are running on a NUMA machine We suggest launching mongod like this to avoid performance problems: ** numactl –interleave=all mongod [other options]

Mongo was working fine in my Ubuntu machine, but whenever I access mongo shell, it will display the following warning.

root@abc:~# mongo
MongoDB shell version: 2.4.5
connecting to: test
Server has startup warnings:
Tue Aug 13 03:47:13.764 [initandlisten]
Tue Aug 13 03:47:13.764 [initandlisten] ** WARNING: You are running on a NUMA machine.
Tue Aug 13 03:47:13.764 [initandlisten] **          We suggest launching mongod like this to avoid performance problems:
Tue Aug 13 03:47:13.764 [initandlisten] **¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† numactl –interleave=all mongod [other options]
Tue Aug 13 03:47:13.764 [initandlisten]

First I checked, whether my hardware is NUMA(Non-Uniform Access Memory) enabled. I got the following output which said the answer is yes, it is NUMA enabled.

root@abcl# ...

Read More

PHP cannot access MongoDB, you need to install the Mongo extension for PHP.

When you access the phpMoAdmin to manage your mongo databases, sometimes you may get the following error.

PHP cannot access MongoDB, you need to install the Mongo extension for PHP.”

This is because mongo is installed, but the mongo extension for php is not installed. You can install it using pecl.

pecl install mongo

Once it finishes, add the mongo.so file to your php.ini and restart apache.

You can find your php.ini as follows.

php -i | grep ini and check for the following line

“Loaded Configuration File => /usr/local/lib/php.ini”

Now open that file and make the changes

vi /usr/local/lib/php.ini

Add the following down to any already present extensions

extension=”mongo.so”

/etc/rc.d/init.d/httpd restart

Now clear the browser cache and try accessing the phpMoAdmin once again, it shou...

Read More

Install mongodb – Centos/RHEL/Fedora

Install mongodb in CentOS

Depending on the architecture, add the mongo repo to your system.

1)First find if your machine is 32 bit or 64 bit as follows.

uname -m

i686 – it is 32 bit
x86_64 – it is 64 bit.

2) Create the mongo repo as follows.

# vi /etc/yum.repos.d/10gen.repo

If it is 32bit machine, add the following to the file.

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0
enabled=1

If it is a 64bit machine, use the following.

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1

3) Now you can use yum to install mongo.

yum install mongo-10gen mongo-10gen-server

Mongo is now installed and you can start and stop mongo as follows.

/etc/rc.d/init...

Read More

MSSQL: Error: dbbackup failed: Unable to restore database

Sometimes, you may get an error as follows while restoring a database in MSSql

Error: dbbackup failed: Unable to restore database 'test_test'
Not valid backup
The media family on device 'C:
WINDOWSTEMPlocalhosttest_testtest.bak' is incorrectly formed.
SQL Server cannot process this media family.
VERIFY DATABASE is terminating abnormally.

Most probably this error occurs when you are trying to restore an SQL backup generated in SQL 2008 to an SQL 2005 server. So, to get it correctly restored, we need to make the backup 2005 compatible. You can do it as follows.

1) Open SQL Server Management Studio2008. In 'Object Explorer', right click the database that you want to convert.

Select 'Tasks' > 'Generate Scripts'. 

2) Click 'Next'...
Read More