ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (111)
[root@Hadoop ~]# mysql
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (111)
[root@Hadoop ~]# mysqld install
-bash: mysqld: command not found
[root@Hadoop ~]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
解决办法:
[root@Hadoop ~]# rm -fr /var/lib/mysql/*
[root@Hadoop ~]# service mysqld start
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Sat Feb 29 05:13:58 2020 from 192.168.184.1
[root@Hadoop ~]# mysql
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (111)
[root@Hadoop ~]# mysqld install
-bash: mysqld: command not found
[root@Hadoop ~]# service mysqld start
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
[root@Hadoop ~]# /etc/inint.d/mysql start
-bash: /etc/inint.d/mysql: No such file or directory
[root@Hadoop ~]# mysql --help| grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
[root@Hadoop ~]# service mysql restart
mysql: unrecognized service
[root@Hadoop ~]# service mysqld restart
Stopping mysqld: [ OK ]
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
[root@Hadoop ~]# rm -fr /var/lib/mysql/*
[root@Hadoop ~]# service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h Hadoop password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
[ OK ]
Starting mysqld: [ OK ]
[root@Hadoop ~]#
然后重新启动,正常!