配置单元错误:“无法通过套接字连接到本地mysql服务器”

ev7lccsx  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(200)

我在centos 7中安装了mysql server:

[root@master1 ~]# rpm -qa | grep mysql
mysql-community-release-el7-5.noarch
mysql-community-server-5.6.39-2.el7.x86_64
mysql-community-common-5.6.39-2.el7.x86_64
mysql-community-client-5.6.39-2.el7.x86_64
mysql-community-libs-5.6.39-2.el7.x86_64

现在我需要执行以下命令:

mysql -u root -p welcome123 
CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hivepwd';

但是,我得到以下错误:

[root@master1 ~]# mysql -u root -p welcome123
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

我读了一些有必要检查的建议 my.cnf 但是我找不到这个文件:

[root@master1 ~]# vi /etc/mysql/my.cnf
[root@master1 ~]# cd /etc/mysql/
-bash: cd: /etc/mysql/: No such file or directory

最后,我尝试重置密码:

[root@master1 ~]# mysqladmin password newpassword
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

我也试过了 /usr/bin/mysql_secure_installation . 它要求我输入根密码。所以,我生成了密码,但它不被接受,并提供了上面显示的错误。

grep 'A temporary password is generated for root@localhost' /var/log/mysqld.log |tail -1

附笔
我认为mysql服务器实际上没有运行:

[root@master1 ~]# ps -ef | grep mysql
root     17964     1  0 17:12 ?        00:00:00 /bin/bash /usr/bin/mysql-systemd-start post
root     20359 14673  0 17:17 pts/0    00:00:00 /usr/bin/perl /usr/bin/mysql_secure_installation
root     21799 14673  0 17:21 pts/0    00:00:00 grep --color=auto mysql

然后我重新安装它以防万一:

[root@master1 ~]# yum install -y mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.uv.es
 * extras: mirror.uv.es
 * updates: mirror.uv.es
Package mysql-community-server-5.6.39-2.el7.x86_64 already installed and latest version
Nothing to do

当我想启动服务时,它将永远持续:

[root@master1 ~]# systemctl start mysqld.service

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题