2011-11-24 40 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。謝謝馬克。在嘗試其他一些事情之前應該早已問過這個問題..... :) –