以root身份:
/* Main Function */
int main(void) {
/* Declare and initialize Variables */
double temp, conduc, tempsqrd, temptconduc, sumtemp, sumconduc;
double sumtempsqrd, sumtemptconduc, slope, yint;
int i, ndata;
FILE *therm, *out;
/* Open Files */
therm = fopen(inputfile, "r");
out = fopen(outputfile, "w");
/* print output headings */
printf("******************************************");
printf("\n TEMPERATURE vs THERMAL CONDUCTIVITY"
"\n by Tyrus Sonneborn"
"\n\nTemp Conduct Temp Sqrd Temp*Conduct");
fprintf(out, "******************************************");
fprintf(out, "\n TEMPERATURE vs THERMAL CONDUCTIVITY"
"\n by Tyrus Sonneborn"
"\n\nTemp Conduct Temp Sqrd Temp*Conduct");
/* Verify input file and read control number */
if (therm == NULL) {
printf("\n\n\n\n ERROR OPENING INPUT FILE.");
printf("\n\n PROGRAM TERMINATED.\n\n\n");
return 0;
} else {
/* Read control number */
fscanf(therm, "%i", &ndata);
/* Compute the conductivity data and sums. */
for (i = 1; i <= ndata; i++) {
fscanf(therm, "%lf %lf", &temp, &conduc);
sumconduc = conduc + sumconduc;
tempsqrd = pow(temp, 2);
temptconduc = temp * conduc;
sumtemp = temp + sumtemp;
sumtempsqrd = sumtempsqrd;
sumtemptconduc = sumtemptconduc;
printf("\n %3f %4.0f %6.0f %6.0f",
temp, conduc, tempsqrd, temptconduc);
fprintf(out, "\n %3f %5.1f %6.0f %6.0f",
temp, conduc, tempsqrd, temptconduc);
}
}
/* computing the slope and y intercept */
slope = (sumtemp * sumconduc - ndata * sumtemptconduc) / (pow(sumtemp, 2) - ndata * (pow(sumtemp, 2)));
yint = (sumconduc - slope * sumtemp) / ndata;
printf("\n\n%10f, %10f, %10f, %10f",
sumtemp, sumconduc, sumtempsqrd, sumtemptconduc);
fprintf(out, "\n\n%10f, %10f, %10f, %10f",
sumtemp, sumconduc, sumtempsqrd, sumtemptconduc);
在PHP中:
SHOW DATABASES;
DROP DATABASE IF EXISTS conman;
Create Database conman;
USE conman;
CREATE TABLE contact_info(
firstname varchar(25),
middleinitial char(1),
lastname varchar(25),
suffix_description varchar(5),
title_description varchar(5),
jobtitle varchar(40),
department varchar(30),
email varchar(35),
url varchar(50),
IMaddress varchar(25),
phone_number varchar(25),
phonetype_description varchar(10),
birthday date,
notes varchar(255),
companyname varchar(30),
addressLine1 varchar(40),
addressLine2 varchar(45),
city varchar(25),
state_province varchar(20),
zip_postalcode varchar(10),
country_region varchar(15),
companyURL varchar(45),
companyPhone varchar(12)
);
INSERT INTO contact_info
(
firstName,
middleInitial,
lastName,
suffixDescription,
titleDescription,
jobTitle,
department,
email,
url,
IMaddress,
phoneNumber,
phoneDescription,
birthday,
notes,
companyName,
addressLine1,
addressLine2,
city,
state_province,
zip_postalcode,
country_region,
companyURL,
companyPhone
)
VALUES
(
'Jacob',
'P',
'Jacobson',
'Jr',
'Mr',
'Director',
'Finance',
'rjameson@concor.com',
'www.concor.com/~rjames',
'jpjacobson',
'323-546-6834',
'work',
'1969-07-13',
'All meetings must be scheduled through Charlene Renolds',
'Concor International, Inc.',
'143 South Main Street',
'',
'Los Angeles',
'CA',
'90012-3712',
'USA',
'www.concor.com',
'323-546-6834'
)
错误讯息:
GRANT ALL PRIVILEGES ON * . * To 'JKR'@'%' IDENTIFIED BY "";
FLUSH PRIVILEGES;
由于某种原因只能以root身份运行...
我怎么得到$con = new PDO("mysql:host=127.0.0.1;dbname=jkr;charset=utf8", "JKR", "");
?
答案 0 :(得分:1)
您的系统上很可能有匿名用户''@'localhost'
。匿名用户是忽略名称的用户。
如果您使用来自JKR
的{{1}}连接到MySQL,它将与匿名用户匹配。
您可以使用localhost
有关MySQL匹配用户和权限的方式的详细讨论,请参阅https://dev.mysql.com/doc/refman/5.7/en/connection-access.html。
答案 1 :(得分:1)
在我的情况下,mysql帐户是REQUIRE SSL
;必须提供ssl_ca
文件(至少)。其他ssl参数位于:http://dev.mysql.com/doc/refman/5.7/en/secure-connection-options.html