如何检查 mysql 是否安装在 ubuntu 上?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27614574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I check if mysql is installed on ubuntu?
提问by Green Lei
I need to check if mysql is installed on a ubuntu server. Is there a way to determine if mySql has been installed ? Thanks.
我需要检查 mysql 是否安装在 ubuntu 服务器上。有没有办法确定是否已安装 mySql?谢谢。
回答by hd1
回答by Gerald Schade
"mysql" may be found even if mysql and mariadb is uninstalled, but not "mysqld".
即使卸载了mysql和mariadb,也可能会找到“mysql”,但不会找到“mysqld”。
Faster than rpm -qa | grep mysqld is:
比rpm -qa 快 grep mysqld 是:
which mysqld
回答by Ryan
Multiple ways of searching for the program.
多种搜索程序的方式。
Type mysqlin your terminal, see the result.
输入mysql您的终端,查看结果。
Search the /usr/bin, /bindirectories for the binary.
在/usr/bin,/bin目录中搜索二进制文件。
Type apt-cache show mysqlto see if it is installed
键入apt-cache show mysql以查看是否已安装
locate mysql
locate mysql
回答by Anmol Mourya
With this command:
使用此命令:
dpkg -s mysql-server | grep Status
回答by krunal patel
In an RPM-based Linux, you can check presence of MySQL like this:
在基于 RPM 的 Linux 中,您可以像这样检查 MySQL 的存在:
rpm -qa | grep mysql
rpm -qa | mysql
For debian or other dpkg-based systems, check like this:*
对于 debian 或其他基于 dpkg 的系统,请按以下方式检查:*
dpkg -l mysql-server libmysqlclientdev*
dpkg -l mysql-server libmysqlclientdev*
*
*
回答by Jayesh
# mysqladmin -u root -p status
Output:
输出:
Enter password:
Uptime: 4 Threads: 1 Questions: 62 Slow queries: 0 Opens: 51 Flush tables: 1 Open tables: 45 Queries per second avg: 15.500
It means MySQL serer is running
这意味着 MySQL serer 正在运行
If server is not running then it will dump error as follows
如果服务器没有运行,那么它将转储错误如下
# mysqladmin -u root -p status
Output :
输出 :
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
So Under Debian Linux you can type following command
所以在 Debian Linux 下你可以输入以下命令
# /etc/init.d/mysql status
回答by Usman
Try executing 'mysql' or 'mysql -- version' without quotes on terminal. it will prompt version otherwise Command Not Found
尝试在终端上执行不带引号的 'mysql' 或 'mysql --version'。它会提示版本,否则找不到命令

