Home Database Mysql Tutorial MySQL登陆问题总结_MySQL

MySQL登陆问题总结_MySQL

Jun 01, 2016 pm 01:41 PM
system

bitsCN.com 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:      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      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)      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:      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 bitsCN.com

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CUDA's universal matrix multiplication: from entry to proficiency! CUDA's universal matrix multiplication: from entry to proficiency! Mar 25, 2024 pm 12:30 PM

CUDA's universal matrix multiplication: from entry to proficiency!

Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time Jul 30, 2024 pm 02:17 PM

Huawei's Qiankun ADS3.0 intelligent driving system will be launched in August and will be launched on Xiangjie S9 for the first time

Which version of Apple 16 system is the best? Which version of Apple 16 system is the best? Mar 08, 2024 pm 05:16 PM

Which version of Apple 16 system is the best?

What are the computer operating systems? What are the computer operating systems? Jan 12, 2024 pm 03:12 PM

What are the computer operating systems?

How to solve the 0xc0000428 error in win10 system How to solve the 0xc0000428 error in win10 system Dec 27, 2023 pm 04:41 PM

How to solve the 0xc0000428 error in win10 system

Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use Jun 02, 2024 pm 02:58 PM

Always new! Huawei Mate60 series upgrades to HarmonyOS 4.2: AI cloud enhancement, Xiaoyi Dialect is so easy to use

Differences and similarities of cmd commands in Linux and Windows systems Differences and similarities of cmd commands in Linux and Windows systems Mar 15, 2024 am 08:12 AM

Differences and similarities of cmd commands in Linux and Windows systems

Where is the system font storage path? Where is the system font storage path? Feb 19, 2024 pm 09:11 PM

Where is the system font storage path?

See all articles