I used these lines of code but in the table it is showing null
create table Picture( imageID integer primary key, image blob);
insert into Picture values(1, LOAD_FILE('D:\\flower.gif'));
select * from Picture;
Please someone help me to resolve this problem. I'm using MySQL. You can give me solution for MySQL and SQL Developer also.
The Fine Manual explains:
The FILE privilege gives you permission to read and write files on the server host using ... the LOAD_FILE() function. A user who has the FILE privilege can read any file on the server host that is either world-readable or readable by the MySQL server.
You didn't share any SHOW GRANT output with us.
Consider issuing a GRANT FILE ON *.* TO 'X'#'Y' command.
Also, if your connect string refers to a machine other than localhost, you will need to verify the .gif file is readable on that server machine, rather than on your client machine. The uid that mysqld is running under is the one that needs filesystem read permission.
Related
I'm trying to insert a record from an SQL Server into a MySQL instance that's connected as a linked server.
Here's basically what I'm doing:
INSERT INTO OPENQUERY(LINKED_SERVER,
'SELECT
id,
claimed
FROM MySQLTable;'
)
SELECT
Id,
'0'--claimed
FROM
MSSQLTable
And I'm getting this error:
The OLE DB provider "MSDASQL" for linked server "LINKED_SERVER" could not INSERT INTO table "[MSDASQL]" because of column "claimed". The user did not have permission to write to the column.
The linked server is currently configured to use the root user on the MySQL database and I've checked the privileges using GRANT and they seem fine:
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY PASSWORD '******' WITH GRANT OPTION
The 'claimed' column is an enum column defined as "enum('1','0')". I have a feeling that it's the enum aspect that's messing things up, but I don't know why.
I use a similar process to insert data elsewhere so I know that it should work in principle, but I just can't figure out why this column is being such a pain!
It would appear that this is a known issue with older versions of MySQL linked servers and OPENQUERY isn't the right tool for the job. Instead I rewrote the query to use EXEC (INSERT...) AT [LINKED_SERVER], and it worked like a charm.
This syntax is available from SQL Server 2005 onwards.
The more you know...
Deployed a new version of our app on heroku and migrated over database from previous free jawsdb instance. However now every time user signs up gives
(Mysql2::Error: INSERT command denied to user <username for instance
what have i missed
migrated using a dump and re-import using mysql command line. eye balled exported data and it seems to be there (user emails etc)
all config vars look ok (DATABASE_URL is mysql2...)
i can login to the database via the url
I have not had to grant access or anything like that before, anyone come across this?
thanks
Ben
My guess is they disabled your INSERT grant because you have reached your max Storage Capacity for your plan.
To validate this is a permissions problem, log into a MySQL prompt with the user the app is running as, and enter this query:
SHOW GRANTS;
It probably list many, but no INSERT.
See this link. As explained in given link, jawsdb preliminary plan does not give you permission to add a new database. You are provided with one schema with some random name and you have to work with that only.
Check your migration
e.g. Make sure the database name matches.
For me, I got the same error as OP when trying to migrate my data. This was a fresh account with only a 50kb'ish database; nowhere close to the free-plan 5mb limit.
In my SQL export statement, my local database name is being used, however the remote MySQL (ie JawsDB) service auto-generates a db name, which will obviously not be the same. Simply used find-replace to change the database name to match remote; everything works.
I have a website written in php and mysql (written by someone else) and I need to alter it- just for your interest it is bridgetjonesart.co.uk. So I thought I would download it to my desktop pc and use easy php and mysql locally to make changes then upload it again.
I seem to have downloaded everything okay. I first just tried to run existing php using Easy Php and got
Warning: mysql_connect(): Access denied for user 'runningc'#'localhost' (using password: YES) in C:\Program Files (x86)\EasyPHP-12.1\www\backup from runningc\public_html\bridgetjonesart.co.uk\mysqlLogin\mysql_connect.php on line 6
Could not connect to database. Error
I have the sql database as a file 'runningc_bjart.sql' in the root directory but I think the php cant see it so I tried to use easy php administration, phpmyadmin and thought perhaps I should import the 'runningc_bjart.sql' file. So I tried and got an error message ...
Error
SQL query:
--
-- Table structure for table `Blog`
--
DROP TABLE IF EXISTS `Blog` ;
MySQL said: Documentation
#1046 - No database selected
I am not sure what to try next, any help would be really appreciated.
Thank you. Bridget
The error messages are VERY clear.
Error #1: You're using the incorrect credentials, or have forgotten to grant rights on your database to the credentials you're using.
Error #2: You've forgotten to set a default database, so MySQL has no idea which database it should be looking in for the table you're trying to drop.
e.g. you need
mysql_select_db('mydatabase');
or change your DROP query to be
DROP TABLE mydatabase.Blog;
With phpmyadmin, create a new database named runningc_bjart and import the file there. Then search in your project for a config file where the db password is set and change it with your local mysql password
I am trying to create a host table in phpMyAdmin for user access and while there is this option below, I cannot find this table to add hosts nor any instructions to create one.
Am I missing something?
Field: Use Host Table
Description: When host table is used, this field is ignored and values stored in Host table are used instead.
Thank you in advance
As of MySQL 5.6.7 the host table is no longer included in the installation of MySQL.
https://dev.mysql.com/doc/refman/5.6/en/grant-tables.html
It used to be that you could use the host table (located at mysql.host) to define allowed hosts for a specific database. It worked something like this:
A user would try to do something (let's say INSERT).
The server would look in the mysql.user table to see if the user had global INSERT privileges.
If the user didn't have global INSERT privileges the server would then look in the mysql.db table to see if the user had DB specific privileges.
If the user had DB specific privileges and the mysql.db.Host field was empty the server would look in the mysql.host table for any hosts that matched the Db field of the mysql.db.Db field.
Assuming it found a match it would allow the INSERT.
If you want to have multiple hosts for a given user read the following:
http://dev.mysql.com/doc/refman/5.6/en/account-names.html
Since a MySQL username is actually 'name'#'host' you could always add multiple users with the same name but different hosts and give them the same privileges.
Why does phpmyadmin still include this feature?
I can only assume that it is for legacy support.
I am working on a remote development server. I have the mysql host name, db name, user name , password of that remote server. I want to setup/replicate/map that dev server mysql in my local phpmyadmin, so that I can access the remote server db locally(for ex :- /mylocalip/remote-server-db).
Thus I don't have to do ssh connection and open the mysql in terminal. How can we do this in phpmyadmin/config.inc.php.
Let me explain again through an example. Lets say the remote server db is accessible through 213.81.203.130/phpmyadmin. I want to access that db from my local ip through an alias name by creating a mapping i.e 192.168.10.140/remote-db. Basically this can be done by adding some sort of code in phpmyadmin/config.inc.php or config.db.php. But how to do it I am not sure.
If you want to avoid using terminal, why not try MySQL Workbench to connect to the database?
UPDATE
In light of all the views to this question, I am adding a solution that more accurately matches the question. Please see this link, I believe it will be helpful. It involves editing the phpmyadmin config.inc.php file to add additional servers. This is how you can keep your localhost connection, and add any remote db connections. Simply select the server from the drop down at the login screen to phpmyadmin.
There are 3 methods to set this up
METHOD #1 : MySQL Replication
Setup MySQL Replication where the Slave has this option
replicate_do_table=mydb.mytable
Then, any DML (INSERT, UPDATE, DELETE) or DDL (ALTER TABLE) you execute will go immediately to serverB. This makes Method #1 is the fastest and most granular approach.
METHOD #2 : Copying the table to the other server
Rather than rehash, Here is an earlier post, Mr. RolandoMySQLDBA did May 31, 2011 for this method : [How do you copy a table from MySqlServer_A to MySqlServer_B?][1]
METHOD #3 : FEDERATED Table (MyISAM Only)
Suppose mytable on serverA looks like this
CREATE TABLE mydb.mytable ( ... ) ENGINE=MyISAM;
You can a mapping of the target table in serverB by running this on serverA like this
CREATE TABLE mydb.mytable_remote LIKE mytable; ALTER TABLE
mydb.mytable_remote ENGINE=FEDERATED
CONNECTION='mysql://username:password#serverB/mydb/mytable';