How to escape the = symbol in .env file - configuration

I try to create an application configuration with .env file, for the first I can get the value of variables for this config.
APPLICATION_NAME=MyApps
LOGGING__LOGLEVEL__DEFAULT=Warning
PROPERTY=value
Result :
Result 1
But, when I try to add ConnectionString variable to .env file. And running my application, the value for this variable always returns null
CONNECTIONSTRINGS__CONN=Database=master;Server=(local);Integrated Security=SSPI;
Result :
Result 2
I think the = symbol on Database=master;Server=(local) will detect as a command. Can anyone help me to explain why this happens, And how to escape the = symbol in .env file?

Related

How to include a variable in a json file for an environment variable?

I have a json file that looks like this:
"redisClient": "redis://127.0.0.1:6379"
However I have recently updated my redis-server to require a password, so I need to include the password before the host. I have an environment variable which is in my .env file which looks like this
REDIS_ACCESS_KEY = SDGJKSDGSJG4124124
I would like to be able to do something along these lines:
"redisClient": "redis://:process.env.REDIS_ACCESS_KEY#127.0.0.1:6379"
But this is not working. How can I include my ACESS_KEY variable so that the end goal is that redisClient = "redis://SDGJKSDGSJG4124124127.0.0.1:6379"?

How to pass parameter to source command in mysql .The parameter is set before to file path

I am tring to import sql file from command prompt. where i use source command and the file path is set into one varible :
set #path='/home/xxx/Downloads/database script/adverise.sql';
source #path
And the error is
ERROR: Failed to open file '#path', error: 2
Thanks in advance
You can simply use the below command, you don't need to put the store into a variable and then use it.
source /home/xxx/Downloads/database script/adverise.sql
If you still need to store the path in a variable then store it into a variable but you can also pass the same path with "source /path/to/file" so that both scenarios will handle.

Updating BLOB from MySQL Workbench

I have a problem with one SQL statement. I am trying to update something in a table which is a Blob field with a pdf. And it's not working.
UPDATE employees
SET resume = LOAD_FILE('C:\Users\gaby\Desktop\sample_resume.pdf')
WHERE id = 1;
If I use the above command the result is null. If I use the below command the result is not null, there is a pdf but it is empty.
UPDATE employees
SET resume = 'C:\Users\gaby\Desktop\sample_resume.pdf'
WHERE id = 1;
I can do this update using JDBC, it works perfect. But I want to do it from workbench too.
Thanks in advance!
I was able to get it done by moving the image(fileName.jpg) file first in to below folder(in my case) C:\ProgramData\MySQL\MySQL Server 5.7\Uploads and then I executed below command and it works for me,
update employees set file=LOAD_FILE('C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/fileName.jpg') where id = 1;
Hope this helps.
Check if all conditions described in the manual are given.
LOAD_FILE(file_name)
Reads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by all and its size less than max_allowed_packet bytes. If the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.
If the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL.
load_file() returns NULL, (at least) one of the conditions must fail.

When I insert a image into MySQL table the result is NULL

What's wrong with this code, I want to insert an image to table, but when I was executed this code the result of image field is NULL.
I try with MySQL Workbench executing:
CREATE TABLE image(keyh int, img blob);
INSERT INTO image VALUES(1, load_file('d:\Picture\cppLogo.png'));
To use this function, the file must be located on the server host, you
must specify the full path name to the file, and you must have the
FILE privilege. The file must be readable by all and its size less
than max_allowed_packet bytes. If the secure_file_priv system variable
is set to a nonempty directory name, the file to be loaded must be
located in that directory.
If the file does not exist or cannot be read because one of the
preceding conditions is not satisfied, the function returns NULL.
http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_load-file
What can you do?
Check which user mysql is running with, and make sure the file is readable by that user. Make sure the security settings allow the file to be read and it is not of greater size than max_allowed_packet.
See SHOW VARIABLES LIKE 'max_allowed_packet'.
For me, it looks like the file is on your localhost and you try to upload it. This is not possible using LOAD_FILE(). The file must be already on the server.
The issue can also be caused by your windows directory seperator character \ (like RiggsFolly said), which is used for escaping instead, switch to unix style / then:
LOAD_FILE('D:/Picture/cppLogo.png')
Or your Image is of greater filesize than a BLOB field can hold, like Balazs Vago said.
i was found the correct syntax is following this:
C:/wamp/binsql5.5.20/data/56VRLRFE.jpg'
not this
C:\wamp\binsql5.5.20\data\56VRLRFE.jpg'
thanks guys for all your Answer :D
Open your MySql Command Line Client and login with root user and type
mysql> SHOW VARIABLES LIKE "secure_file_priv";
this will show you the secure path used by MySql to access the files. something like
+------------------+-----------------------+
| Variable_name | Value |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
you can either paste files inside this folder or change the "secure_file_priv" variable value to "empty string" so that it can read file from anywhere.
On Windows the fundamental problem is that MySql, by default, runs as a Windows service under the Network account which means that there are only a few file locations the server can access. Thus for load_file to work, the file must be placed in a folder on the server which can be read by the service. There seems to be no documentation on this. In my investigation the only folder that works with load_file is C:\ProgramData\MySQL\MySQL Server 8.0\Uploads
Run a query to test the load...
select load_file('C:\\ProgramData\\MySQL\\MySQL Server 8.0\\Uploads\\1.txt') ;
Note on windows you have to use either double \ or / to separate the path elements. This will return NULL on failure, otherwise the contents of the file.
Assume now a table named db.image with columns source and image. Source is character and image is blob. The command to load a.jpg into the table would be
insert into db.image (source,image) values ('a.jpg',load_file('c:/programdata/mysql/mysql server 8.0/uploads/a.jpg'));
Store Directly Without folder name for example-
create table myimg(id int, image mediumblob);
insert into myimg values(101, load_file("E://xyz.png"));

How to check current strings in MYSQL_HISTIGNORE?

In mysql 5.6 a new parameter histignore is introduced to avoid writing of history file for some particular keywords.
I run the mysql shell by setting two string in histignore parameter as:
./bin/mysql --histignore="*UPDATE*:*DELETE*"
I want to know how to check this variable current values ?
Whats the command to check present values of this variable ?
I got the solution:
We need to set the variable as:
export MYSQL_HISTIGNORE="*INSERT*"
and we can check via command :
printenv MYSQL_HISTIGNORE