如何使用bash在mysql表中插入一行-当使用$时?
我试图使用bash在MySQL表中插入一行,我已将下面的脚本保存为script.sh,并使用 bash script.sh 当脚本执行时,它是成功的,没有错误,但是包含加密值(“$2b$10$FywS3Lc27let0C9VVvZYFOBYg.AwGA3VEtUs5YIAjjUWSSEI3Fqt2”)的密码字段存储为其他值,如 b0.AwGA3VEtUs5YIAjjUWSSEI3Fqt2 而不是 $2b$10$fyws3lc27let0c9vvzyfobyg.AwGA3VEtUs5YIAjjUWSSEI3Fqt2 我试着使用“”和“”以及“”,但都不起作用 那么,当有$value时,如何插入如何使用bash在mysql表中插入一行-当使用$时?,mysql,linux,bash,shell,Mysql,Linux,Bash,Shell,我试图使用bash在MySQL表中插入一行,我已将下面的脚本保存为script.sh,并使用 bash script.sh 当脚本执行时,它是成功的,没有错误,但是包含加密值(“$2b$10$FywS3Lc27let0C9VVvZYFOBYg.AwGA3VEtUs5YIAjjUWSSEI3Fqt2”)的密码字段存储为其他值,如 b0.AwGA3VEtUs5YIAjjUWSSEI3Fqt2 而不是 $2b$10$fyws3lc27let0c9vvzyfobyg.AwGA3VEtUs5YIAjjUW
#!/bin/bash
mysql <<EOF
GRANT ALL PRIVILEGES ON *.* TO "test_mysql_user"@"localhost" IDENTIFIED BY "test_password";
FLUSH PRIVILEGES;
create database cricket;
use cricket;
//created tables
.....
.....
INSERT INTO admin
(
admin_id,
first_name,
middle_name,
last_name,
email_id,
password,
address,
city,
state,
zip_code,
country,
phone_code,
phone_number,
email_campaign)
VALUES
(
'root',
'root',
'root',
'root',
'root@gmail.com',
'$2b$10$FywS3Lc27let0C9VVvZYFOBYg.AwGA3VEtUs5YIAjjUWSSEI3Fqt2', //this field is the error , saved as someother value
'root',
'root',
'root',
'root',
'root',
'root',
'root',
'root');
EOF
#/bin/bash
mysql如果不希望参数替换,则必须引用'EOF'
字符串
从manbash | less+/“heredocuments”
这里是文档
这种类型的重定向指示shell从当前源读取输入,直到一行只包含单词
(无尾随空白)可见。然后,所有读取到该点的行都将用作
指挥部
此处文件的格式为:
<<[-]word
here-document
delimiter
如果不希望进行参数替换,则必须引用'EOF'
字符串
从manbash | less+/“heredocuments”
这里是文档
这种类型的重定向指示shell从当前源读取输入,直到一行只包含单词
(无尾随空白)可见。然后,所有读取到该点的行都将用作
指挥部
此处文件的格式为:
<<[-]word
here-document
delimiter
考虑使用源命令。这可能是一个快速的工作。考虑使用源命令。这可能是一个快速的解决办法。
password='$2b$10$FywS3Lc27let0C9VVvZYFOBYg.AwGA3VEtUs5YIAjjUWSSEI3Fqt2'
mysql <<EOF
INSERT INTO admin
(
admin_id,
first_name,
middle_name,
last_name,
email_id,
password,
address,
city,
state,
zip_code,
country,
phone_code,
phone_number,
email_campaign)
VALUES
(
'root',
'root',
'root',
'root',
'root@gmail.com',
'$password',
'root',
'root',
'root',
'root',
'root',
'root',
'root',
'root');
EOF