doucang8303 2015-05-13 01:57
浏览 366

MySQL有两个不同的密码?

I am sure they are passwords to different things but i am not sure what. When in terminal to connect to MySQL I enter /usr/LOCAL/mysql/BIN/mysql -h host -u username -p I am then prompted for a password and the password is ''. But when connecting to MySQL with PHP I use the following code and it works

DEFINE('DB_HOST', 'localhost'); 
DEFINE('DB_USER', 'root'); 
DEFINE('DB_PASS', 'root'); 

$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASS,) or 
die('could not connect: '. mysqli_connect_error() );

If i were to use DEFINE('DB_PASS', ''); it returns "Access denied for user 'root'@'localhost' (using password: NO)", why does there appear to be two separate passwords?

  • 写回答

2条回答 默认 最新

  • doufang3001 2015-05-13 02:04
    关注

    MySQL uses $user/$host/$password comparison by default, so your current setup has two different user accounts in MySQL - root and whatever username you supply on the command line. Each of those has its own password.

    Also, if the account has no (ie empty) password you don't need to specify the -p flag on the CLI

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)