mysql5 - 由于 'root' 无法创建数据库或执行任何操作(拒绝访问)

标签 mysql macos osx-lion macports mysql5

我在 Mac OS X Lion 上,刚刚使用 MacPorts 安装了 mysql5。

然后我成功运行了:

sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql

我可以启动服务器并以“root”身份正常连接,但我无法创建任何数据库。

$ mysql5 -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.61 Source distribution

mysql> create database dbname;
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'dbname'

我做了很多谷歌搜索试图解决这个问题,看来问题可能与/opt/local/var/db/mysql5 的文件系统权限有关,但我已经尝试更改这些无济于事:

$ ls -l /opt/local/var/db/
total 0
drwxrwxrwx  8 _mysql  _mysql  272 Apr 12 11:55 mysql5

我试验过所有者是“_mysql”、“mysql”和“root:wheel”,但它们都没有产生影响。

最佳答案

已修复——mysql 创建了我的“root”帐户但没有权限(我是 mysql 新手)。

我通过启动 mysql 来解决

--skip-grant-tables

然后启动:

mysql5

并运行:

mysql> UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> GRANT ALL ON *.* TO 'root'@'localhost';

希望这对某人有帮助!

关于mysql5 - 由于 'root' 无法创建数据库或执行任何操作(拒绝访问),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10130296/

相关文章:

PHP - 来自 mysql 的 json_decode

mysql - 从日期格式中删除字母并保存在 sql 表的下一列中

ios - 无法更新 XCode : Not enough space

macos - 10.7 上的 ARC 迁移工具给出错误 : it is not safe to remove an unused 'autorelease' message

mysql - 内部连接函数错误

MySQL - 条件 WHERE

xcode - 如何清除Mac应用程序的Xcode构建的UserDefaults?

macos - XPC 服务和 AVFoundation

macos - 运行需要从根终端访问钥匙串(keychain)的 cocoa 应用程序

java - 使用 java 获取 mac 操作系统上的常见 mac 地址