PHP连接到MySQL

时间:2018-09-29 06:55:16

标签: php mysql xampp

很抱歉遇到这样的初学者问题,但是我才刚刚开始学习PHP。

我的代码如下:

        let ballWithOrientation = getNewBallNode() // return ball node + position
        let ballNode = ballWithOrientation.ball // it is the SCNNode
        self.sceneView.scene.rootNode.addChildNode(ballNode ?? SCNNode()) // Added to the scene 
        let cameraPosition =  self.sceneView.pointOfView?.worldFront

        let target =  SCNVector3(Double(cameraPosition?.x ?? 1) * forceVector,Double (cameraPosition?.y  ?? 1) * forceVector,Double(cameraPosition?.z ?? 1) * forceVector) // Vector of direction 
        let throwSpeed = self.calculateBestThrowSpeed(origin: ballNode!.position, target:target , timeToTarget: 0.66)  Calculated vector with velocity 
        ballNode?.physicsBody?.applyForce(throwSpeed, asImpulse: true) // apply force 

我在my.ini文件中设置了密码: enter image description here

但是我收到一条错误消息: enter image description here

它表明问题出在第11行,但我不知道出了什么问题。

2 个答案:

答案 0 :(得分:0)

首先,进入mysql,然后进入exec

grant all privileges on *.* to user@localhost identified by 'password';
flush privileges;

根据需要替换用户名和密码

答案 1 :(得分:0)

您未在my.ini文件中设置用户/密码。您也可能不应该登录到您的数据库中。请参阅以下内容: Creating accounts

您也可能也不应该以{{1​​}}的身份通过php登录MySQL,这就是为什么您应该为此目的创建唯一用户的原因。