SQLSTATE [HY000] [2005] Laravel中未知的MySQL服务器主机''(2)

编程入门 行业动态 更新时间:2024-10-26 08:33:30
本文介绍了SQLSTATE [HY000] [2005] Laravel中未知的MySQL服务器主机''(2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在laravel中进行简单登录,尝试执行身份验证时出现错误.这是一个相当奇怪的连接错误

Hi I am making a simple login in laravel and I get an error when I try to perform an authentication. It is a rather odd connection error

连接

'mysql' => array( 'driver' => 'mysql', 'host' => 'Marsur', 'database' => 'database', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'options' => array( PDO::ATTR_PERSISTENT => true, ), ),

控制器

public function doLogin(){ $rules = array('correo' => 'required|email', 'password' => 'required'); $validator = Validator::make(Input::all(), $rules); if($validator->fails()){ return Redirect::to('usuario') ->withErrors($validator)// manda los errores al login ->withInput(Input::except('password')); // }else{ $userData = array( 'Correo' => Input::get('correo'), 'Contrasena' => Input::get('password') ); if(Auth::attempt($userData)){ echo 'bien'; }else{ return Redirect::to('login'); } } }

型号*

class Usuario extends Eloquent{ protected $table = 'Usuario'; protected $primaryKey = 'idUsuario'; protected $fillable = array('Nombre', 'Apellido', 'TipoUsuario', 'Contrasena', 'Correo', 'Telefono'); }

我该如何解决?

推荐答案

Marsur几乎可以肯定不是有效的主机名.

Marsur is almost certainly not a valid hostname.

通常,主机名是IP地址或localhost.在某些情况下,您可以通过主机名来引用远程服务器,但是在这种情况下,它的名称看起来像一个网址.

Generally a hostname is an IP address, or localhost. On some occasions you may refer to a remote server by its hostname, but in such a case it will have a name that looks like a web address.

所以...解决这个问题.如果您的数据库与其余代码位于同一台物理计算机上,则需要localhost.

So... fix that. If your database is on the same physical machine as the rest of your code, then you need localhost.

更多推荐

SQLSTATE [HY000] [2005] Laravel中未知的MySQL服务器主机''(2)

本文发布于:2023-10-26 01:18:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1528655.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主机   服务器   SQLSTATE   MySQL   Laravel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!