问题出现的原因,是我关闭了MySQL,而且是所有关于MySQL的进程都关闭了,这是问题出现的原因。
出现这个问题后,不要慌,直接命令行输入:service mysql restart
这个是mysql重启命令.
下面,我把我的具体命令过程贴上去,给大家点启发:
andylau@ubuntu:~$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
andylau@ubuntu:~$ /etc/inint.d/mysql start
bash: /etc/inint.d/mysql: No such file or directory
andylau@ubuntu:~$ sudo /etc/inint.d/mysql start
[sudo] password for andylau:
sudo: /etc/inint.d/mysql: command not found
andylau@ubuntu:~$ service mysql restart
andylau@ubuntu:~$ mysql
ERROR 1045 (28000): Access denied for user 'andylau'@'localhost' (using password: NO)
andylau@ubuntu:~$ mysql -uroot -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
andylau@ubuntu:~$ sudo mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.30-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
可以看到,紧固一番摸索,终于打开了mysql .