我在 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/