找不到命令“ mysql”,但是即使已安装命令也可以安装,怎么可能出现错误?

时间:2019-04-25 14:21:37

标签: mysql ubuntu-18.04

所以问题由此开始。

  1. 我无法登录mysql,因此我通过在ubuntu 18.04中使用以下命令将其完全删除。
$ sudo apt-get remove --purge mysql-server mysql-client mysql-common -y
$ sudo apt-get autoremove -y
$ sudo apt-get autoclean

$ rm -rf /etc/mysql
rm: cannot remove '/etc/mysql/debian.cnf': Permission denied
rm: cannot remove '/etc/mysql/debian-start': Permission denied
rm: cannot remove '/etc/mysql/mysql.cnf': Permission denied
rm: cannot remove '/etc/mysql/my.cnf.fallback': Permission denied
rm: cannot remove '/etc/mysql/mysql.conf.d/mysqld.cnf': Permission denied
rm: cannot remove '/etc/mysql/mysql.conf.d/mysqld_safe_syslog.cnf': Permission denied
rm: cannot remove '/etc/mysql/conf.d/mysqldump.cnf': Permission denied
rm: cannot remove '/etc/mysql/conf.d/mysql.cnf': Permission denied
rm: cannot remove '/etc/mysql/my.cnf': Permission denied

$ sudo rm -rf /etc/mysql

$ sudo find / -iname 'mysql*' -exec rm -rf {} \;
find: ‘/var/lib/mysql’: No such file or directory
find: ‘/var/lib/mysql-keyring’: No such file or directory
find: ‘/var/lib/mysql-files’: No such file or directory
find: ‘/var/lib/mysql-upgrade’: No such file or directory
find: ‘/var/log/mysql’: No such file or directory
rm: cannot remove '/snap/core/6673/etc/apparmor.d/abstractions/mysql': Read-only file system
rm: cannot remove '/snap/core/6673/usr/share/bash-completion/completions/mysql': Read-only file system
rm: cannot remove '/snap/core/6673/usr/share/bash-completion/completions/mysqladmin': Read-only file system
rm: cannot remove '/snap/core/6350/etc/apparmor.d/abstractions/mysql': Read-only file system
rm: cannot remove '/snap/core/6350/usr/share/bash-completion/completions/mysql': Read-only file system
rm: cannot remove '/snap/core/6350/usr/share/bash-completion/completions/mysqladmin': Read-only file system
find: ‘/usr/share/mysql’: No such file or directory
find: ‘/usr/share/dbconfig-common/scripts/phpmyadmin/upgrade/mysql’: No such file or directory
find: ‘/usr/share/dbconfig-common/data/phpmyadmin/upgrade/mysql’: No such file or directory
find: ‘/usr/share/mysql-common’: No such file or directory
find: ‘/usr/share/php7.2-mysql/mysql’: No such file or directory
find: ‘/usr/share/doc/mysql-client-core-5.7’: No such file or directory
find: ‘/usr/share/doc/mysql-common’: No such file or directory
find: ‘/usr/share/doc/mysql-server-core-5.7’: No such file or directory
find: ‘/usr/share/doc/mysql-client-5.7’: No such file or directory
find: ‘/usr/share/doc/mysql-server-5.7’: No such file or directory
find: ‘/usr/lib/mysql’: No such file or directory

2。然后我使用以下命令进行了全新安装

$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  mysql-server
0 upgraded, 1 newly installed, 0 to remove and 70 not upgraded.
Need to get 9944 B of archives.
After this operation, 110 kB of additional disk space will be used.
Get:1 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server all 5.7.25-0ubuntu0.18.04.2 [9944 B]
Fetched 9944 B in 0s (21.0 kB/s) 
Selecting previously unselected package mysql-server.
dpkg: warning: files list file for package 'mysql-server-core-5.7' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'mysql-common' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'mysql-server-5.7' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'mysql-client-5.7' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'mysql-client-core-5.7' missing; assuming package has no files currently installed
(Reading database ... 88978 files and directories currently installed.)
Preparing to unpack .../mysql-server_5.7.25-0ubuntu0.18.04.2_all.deb ...
Unpacking mysql-server (5.7.25-0ubuntu0.18.04.2) ...
Setting up mysql-server (5.7.25-0ubuntu0.18.04.2) ...

但是我有问题。

~$ sudo mysql_secure_installation
sudo: mysql_secure_installation: command not found

$ mysql

Command 'mysql' not found, but can be installed with:

sudo apt install mysql-client-core-5.7   
sudo apt install mariadb-client-core-10.1```

我是Linux新手,您能指出我做错了什么以及如何解决该问题。

0 个答案:

没有答案