Ubuntu
為什麼安裝mysql-server包沒有創建root賬號?
這不是*為什麼?*這很重要。這是我自己怎麼做?
我正在使用Ubuntu 10.04 LTS 伺服器。我只想安裝一個 MySQL 伺服器,但由於某種原因它不會讓我。當我執行
apt-get install mysql-server
一切正常。安裝結束時會彈出一個模式視窗,要求我輸入root
密碼。這裡唯一奇怪的是特殊字元的編碼(如模式視窗的邊框)有點混亂。但我認為這不是主要問題。在安裝結束時,MySQL 會自動啟動,一切正常,直到我嘗試登錄。
mysql -u root -p
提示我Enter password:
。我輸入了安裝過程中使用的密碼並收到此錯誤:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
當我使用空密碼嘗試時,我收到相同的錯誤,除了(using password: YES)
變成(using password: NO)
.我做了一些Google研究,並且已經嘗試了所有這些
mysqld_safe --skip-grant-tables &
東西。我還檢查了 mysql 使用者表。唯一的入口是
debian-sys-maint
使用者。mysql> SELECT * FROM user; +-----------+------------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+ | Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | +-----------+------------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+ | localhost | debian-sys-maint | *A632698FAB70686111EB0BE3F732A4C244B6DE8C | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | +-----------+------------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
如果您查看使用者表時確實沒有 root 使用者,那麼您的安裝過程中出現了問題。首先要嘗試的是
sudo dpkg-重新配置
如果這不起作用,那麼您可以嘗試
INSERT INTO user VALUES ('localhost','root',password('newpassword'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); INSERT INTO user VALUES ('127.0.0.1','root',password('newpassword'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); INSERT INTO user VALUES ('ebuntu','root',password('newpassword'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0); flush privileges; quit killall mysqld /etc/init.d/mysql start
第二套命令無恥地從這裡偷走
如果 debconf 要求您輸入 root 使用者的密碼,是因為它試圖創建 root 帳戶。如果不是,是因為您的系統或您正在使用的打包版本中存在錯誤。
我沒有 ubuntu 來檢查它,但你應該在啟動板上尋找類似的問題。