程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> MySQL登陸問題總結

MySQL登陸問題總結

編輯:MySQL綜合教程

MySQL登陸問題總結   想在自己的小本上練習一下MySQL,結果登陸就有問題,折騰了半個小時終於搞定,也把這幾個常見的問題總結下來和大家分享。筆者的系統是OpenSuSE,其他系統的解決方式類似,供大家參考。   首先,登陸MySQL,提示ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2),ps後感覺mysqld是啟動的呀   [plain]   atom@openSuSE:~> mysql -u root -h localhost -p   Enter password:     www.2cto.com   ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2)   atom@openSuSE:~> ps aux | grep mysql   atom      1842  0.0  1.0 265564 41296 ?        Sl   09:15   0:00 /usr/sbin/mysqld --defaults-file=/home/atom/.local/share/akonadi//mysql.conf --datadir=/home/atom/.local/share/akonadi/db_data/ --socket=/home/atom/.local/share/akonadi/socket-openSuSE.site/mysql.socket   atom      2788  0.0  0.0   8276   876 pts/0    S+   09:25   0:00 grep --color=auto mysql  
  但是,查看mysqld的狀態,發現Active: inactive (dead)。。。 [plain]   atom@openSuSE:~> /etc/init.d/mysql status   redirecting to systemctl   mysql.service - LSB: Start the MySQL database server   Loaded: loaded (/etc/init.d/mysql)   Active: inactive (dead)   CGroup: name=systemd:/system/mysql.service   那就再啟動一次,觀察mysql的狀態。
  [plain]   atom@openSuSE:~> sudo /etc/init.d/mysql restart   redirecting to systemctl    www.2cto.com   atom@openSuSE:~> ps aux | grep mysql   atom      1842  0.0  1.0 265564 41296 ?        Sl   09:15   0:00 /usr/sbin/mysqld --defaults-file=/home/atom/.local/share/akonadi//mysql.conf --datadir=/home/atom/.local/share/akonadi/db_data/ --socket=/home/atom/.local/share/akonadi/socket-openSuSE.site/mysql.socket   root     22000  0.0  0.0  11536  1644 ?        S    09:32   0:00 /bin/sh /usr/bin/mysqld_safe --mysqld=mysqld --user=mysql --pid-file=/var/run/mysql/mysqld.pid --socket=/var/run/mysql/mysql.sock --datadir=/var/lib/mysql   mysql    22322  0.2  1.0 721584 42540 ?        Sl   09:32   0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysql/mysqld.log --pid-file=/var/run/mysql/mysqld.pid --socket=/var/run/mysql/mysql.sock --port=3306   atom     22359  0.0  0.0   8276   872 pts/0    S+   09:33   0:00 grep --color=auto mysql   atom@openSuSE:~> /etc/init.d/mysql status   redirecting to systemctl   mysql.service - LSB: Start the MySQL database server   Loaded: loaded (/etc/init.d/mysql)    www.2cto.com   Active: active (running) since Mon, 18 Jun 2012 09:32:43 +0800; 3min 32s ago   Process: 21865 ExecStart=/etc/init.d/mysql start (code=exited, status=0/SUCCESS)   CGroup: name=systemd:/system/mysql.service   ├ 22000 /bin/sh /usr/bin/mysqld_safe --mysqld=mysqld --user=mysql --pid-file=/var/run/mysql/mysqld.pid --socket=...   └ 22322 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mys...  
  這下總算正常了,再嘗試登陸又給出錯誤提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)。 在網上查到一種解決方案,供大家參考。首先,關閉mysqld服務,然後執行下面兩條命令,總算可以進去了,先改密碼~ [plain]   atom@openSuSE:~> sudo /etc/init.d/mysql stop   root's password:    www.2cto.com   redirecting to systemctl   atom@openSuSE:~> sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking &   [1] 22638   atom@openSuSE:~> 120618 09:40:32 mysqld_safe Logging to '/var/log/mysql/mysqld.log'.   120618 09:40:32 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql      atom@openSuSE:~> mysql -u root mysql   [sql]   mysql> UPDATE user SET Password=PASSWORD('xxxx') where USER='root';   mysql> FLUSH PRIVILEGES;   mysql> quit   把PASSWORD('xxxx')中xxxx替換為你自己的密碼。重啟一次,使用設置的新密碼就可以進去了。
    作者 nevasun

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved