pdo为什么不用用户名和密码可以操作成功 $dsn="mysql:host=localhost;dbname=test"; try{ $pdo=newPDO($dsn); echo"连接成功"; }catch(PDOException$e){ echo"连接失败".$e-getMessage(); } try{ $pdo-beginTransaction(); $goodprice=5; $id_out=15; $id_in=
pdo为什么不用用户名和密码可以操作成功
<br /> $dsn = "mysql:host=localhost;dbname=test"; <br /> <br /> try{<br /> $pdo = new PDO($dsn);<br /> echo "连接成功";<br /> }catch(PDOException $e){<br /> echo "连接失败".$e->getMessage();<br /> }<br /> <br /> <br /> try{<br /> $pdo->beginTransaction();<br /> $goodprice = 5;<br /> $id_out = 15;<br /> $id_in =16;<br /> $sql1 ="update price set goodprice【本文来自鸿网互联 (http://www.68idc.cn)】 = goodprice -{$goodprice} where id ={$id_out}";<br /> $sql2 ="update price set goodprice = goodprice +{$goodprice} where id ={$id_in}"; <br /> if(!$affectd_rows =$pdo->exec($sql1)){<br /> throw new PDOException("{$id_out}转出失败");<br /> }<br /> if(!$affectd_rows =$pdo->exec($sql2)){<br /> throw new PDOException("{$id_in}转入失败");<br /> }<br /> $pdo->commit();<br /> echo "提交成功";<br /> }catch(PDOException $e){<br /> echo $e->getMessage();<br /> $pdo->rollback();<br /> } <br />

pdo为什么不用用户名和密码可以操作成功 ?我的数据库名和密码都是root,这有关系吗?
------解决思路----------------------
你肯定还有一个root用户的密码为空
------解决思路----------------------
贴出mysql数据库下user表信息,就知道你的账号信息。
------解决思路----------------------
2个root是空密码 一个什么都不用
------解决思路----------------------
删掉多余用户 然后看看初始的root权限。。
------解决思路----------------------
删掉密码为空的用户,只保留一个root用户,密码为root的那个,看看还能不能连接上

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor
