How can I check if mysql is installed on ubuntu?
MysqlUbuntuMysql Problem Overview
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 Solutions
Solution 1 - Mysql
You can use tool dpkg for managing packages in Debian operating system.
Example
dpkg --get-selections | grep mysql
if it's listed as installed, you got it. Else you need to get it.
Solution 2 - Mysql
"mysql" may be found even if mysql and mariadb is uninstalled, but not "mysqld".
Faster than rpm -qa | grep mysqld is:
which mysqld
Solution 3 - Mysql
Multiple ways of searching for the program.
Type mysql
in your terminal, see the result.
Search the /usr/bin
, /bin
directories for the binary.
Type apt-cache show mysql
to see if it is installed
locate mysql
Solution 4 - Mysql
With this command:
dpkg -s mysql-server | grep Status
Solution 5 - Mysql
# 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
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
# /etc/init.d/mysql status
Solution 6 - Mysql
In an RPM-based Linux, you can check presence of MySQL like this:
rpm -qa | grep mysql
For debian or other dpkg-based systems, check like this: * dpkg -l mysql-server libmysqlclientdev*
Solution 7 - Mysql
Try executing 'mysql' or 'mysql -- version' without quotes on terminal. it will prompt version otherwise Command Not Found