gpt4 book ai didi

mysql - "ERROR 2002 (HY000): Can' t 通过 socket '/var/lib/mysql/mysql.sock' 连接到本地 MySQL 服务器 (2)"getting this on aws linux (centos)

转载 作者:太空宇宙 更新时间:2023-11-04 12:34:53 26 4
gpt4 key购买 nike

我第一次尝试在运行以下命令的 aws linux 实例上安装 mysql

sudo yum install mysql-server
sudo mysql_secure_installation

一旦我运行第二个命令,我就会得到

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Enter current password for root (enter for none):

而且我什至还没有设置我的 root 密码。我应该如何输入我一开始没有设置的密码?

最佳答案

----列出已安装的mysql

sudo yum list installed | grep mysql

----全部删除

sudo yum remove mysql-client mysql-server mysql-common mysql-devel

手动删除一些conf文件:

sudo rm -rf /var/lib/mysql/
sudo rm -rf /etc/my.cnf

尝试重新安装

sudo yum install mysql mysql-server

获取自动生成的密码

sudo grep 'temporary password' /var/log/mysqld.log

mysql -uroot -p

使用autogen密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

希望它能解决您的问题。

https://dev.mysql.com/doc/mysql-installation-excerpt/5.7/en/linux-installation-yum-repo.html

关于mysql - "ERROR 2002 (HY000): Can' t 通过 socket '/var/lib/mysql/mysql.sock' 连接到本地 MySQL 服务器 (2)"getting this on aws linux (centos),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42241768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com