在mysql下用root和空密码登录,运行show grants,结果如下: +---------------------------------------------------------------------+ | Grants for root@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
show grants;看一下结果,---------------------同一个回复不断需要重复。
show grants,结果如下: +---------------------------------------------------------------------+ | Grants for root@localhost | +---------------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
这是你在 Navicat 中显示出来的?!
不是,是命令行显示的,怎么用Navacat运行show grants ?
看下select user,host,password from mysql.user看你都用了哪些登录然后再用再看你用的登录的权限 show grants for 你用的用户@'你用的host'
show grants;看一下结果,估计是没有权限。你是从不同的地方登录的? 要注意MYSQL的用户账号由 username@hostname 组成,即相同的用户名从不同主机登录则是不同的账号。
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/cacti";
Connection connection = null;
try {
Class.forName(driver);
connection = DriverManager.getConnection(url, "cacti", "pass");其余部分省略。
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
现在的感觉是Navicat操作的mysql和命令行下的不一样。
我们的系统在装机时自带了一个mysql,之后又安装了一个更高版本的mysql,和这个有关?