2011-11-24 41 views
2

我已经使用Macports安装了mysql5,安装似乎已结束,但我根本无法登录到服务器。使用Macports默认安装后无法登录到mysql

这是我做过什么:

sudo port install mysql5-server

这种制造和安装的罚款。

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

这也运行良好。它输出以下内容:

Installing MySQL system tables... OK Filling help tables... OK

To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands:

/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password' /opt/local/lib/mysql5/bin/mysqladmin -u root -h LeoMacBook.local password 'new-password'

Alternatively you can run: /opt/local/lib/mysql5/bin/mysql_secure_installation

which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with: cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl cd /opt/local/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!

现在...让我们按照指示完全。我启动服务器:

sudo /opt/local/lib/mysql5/bin/mysqld_safe &

服务器运行正常。

当我尝试更改root密码,我无法登录。

LeoMacBook:bin leonardteo$ /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password' /opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'

我在束手无策。

我已经用--skip-grant-tables启动了服务器。有了这个,我可以从命令行加载mysql,并连接到服务器。当我运行SELECT * FROM mysql.user ;,它返回一个空集!有了这个,我试图通过调用这个命令来创建一个新用户:

CREATE USER 'root'@'localhost' IDENTIFIED BY 'root';

但是这不起作用。我得到的错误:

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

我不能得到这个工作。看起来我很亲密,但root用户似乎失踪了。

任何想法?

伦纳德

回答

4

一旦你启动mysql的用--skip-赠款表,发出flush privileges;查询。这将重新启用权限系统,并允许您运行通常的grantcreate user查询。

+1

BINGO。谢谢马克。在尝试其他一些事情之前应该早已问过这个问题..... :) –