开发者社区> 问答> 正文

看不到表了, 怎么办?报错

root@iZ22xtlue12:/alidata/www/default/path/to/project# mysql -u root -h localhost -p
Enter password:  (为啥不需要输入密码? 输入密码会报错, 密码肯定对的)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 351
Server version: 5.5.37-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.07 sec)

mysql> exit
Bye

展开
收起
爱吃鱼的程序员 2020-06-14 20:57:20 384 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    你是不是更新过mysql了,或者重装过。看起来是配置文件改了,没有访问到原来的数据库路径,而是一个默认位置了。默认安装完mysql,启动后空密码就可以登录的(但是好像看不到库),启动mysql服务时你会看到一个提示,提示你设置管理员密码(命令是<spanstyle="color:#333333;font-family:Arial;font-size:14px;line-height:26px;background-color:#FFFFFF;">mysqladmin-uroot-p...之类,记不太清),只有设置了管理员密码才能登录,这时候就不允许空密码登录了。这个试了还是不行。去你的datadir下看看。

    先检查一下root@localhost的权限

    <preclass="brush:shell;toolbar:true;auto-links:false;">mysql>showgrantsfor'root'@'localhost';



    可能是localhost和127.0.0.1下root用户权限和密码不一样

    2020-06-14 20:57:37
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
15分钟打造你自己的小程序 立即下载
小程序 大世界 立即下载
《15分钟打造你自己的小程序》 立即下载