我在CentOS 7中安装了MySQL服务器:
[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
。它要求我输入root密码。因此,我生成了密码,但未被接受并提供上述错误。
grep 'A temporary password is generated for root@localhost' /var/log/mysqld.log |tail -1
P.S。
我认为MySQL Server实际上并没有运行:
[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