How can I check if mysql is installed on ubuntu?

MysqlUbuntu

Mysql 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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGreen LeiView Question on Stackoverflow
Solution 1 - Mysqlhd1View Answer on Stackoverflow
Solution 2 - MysqlGerald SchadeView Answer on Stackoverflow
Solution 3 - MysqlRyanView Answer on Stackoverflow
Solution 4 - MysqlAnmol MouryaView Answer on Stackoverflow
Solution 5 - MysqlJayeshView Answer on Stackoverflow
Solution 6 - Mysqlkrunal patelView Answer on Stackoverflow
Solution 7 - MysqlUsmanView Answer on Stackoverflow