MySQL登陸問題總結

2021-12-29 21:35:38 字數 3816 閱讀 5713

mysql登陸問題總結

首先,登陸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 --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 --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('***x') where user='root';  

mysql> flush privileges;  

mysql> quit  

把password('***x')中***x替換為你自己的密碼。重啟一次,使用設定的新密碼就可以進去了。  

作者 nevasun

mysql無法登陸問題

有的時候會遇到問題。比如我的是windows10系統,電腦上安裝了mysql,但是無論如何啟動不了,錯誤如圖所示 這種錯誤並不是自己的密碼輸入錯誤,而是因為自己的mysql服務並沒有開啟。那麼問題來了,如何開啟本地的mysql服務呢?1.如下圖所示,找到命令臺,並以管理員身份執行 2.輸入net s...

MySQL8 0登陸問題

一 忽略密碼 mysql出現error1698 28000 access denied for user root localhost錯誤解決方法 在ubuntu的terminal 也即終端 上輸入sudo vim etc mysql mysql.conf.d mysqld.cnf,進入到這個配置檔...

mysql突然不能登陸 mysql不能登陸

前些天還正常執行的mysql,不知怎麼就不能登陸了。錯誤提示為 error 2003 hy000 can t connect to mysql server on localhost 10061 由於伺服器上空間比較小,刪去了一些檔案後,重試,還是不行,排除了因為空間問題導致的不能登陸。嘗試了下面的...