Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Check for mysql installation

Check for mysql installation

Scheduled Pinned Locked Moved C#
mysqlhelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sumit7034
    wrote on last edited by
    #1

    Hi I want to problematically determine if mysql is installed on my machine or not. Please help

    B L 2 Replies Last reply
    0
    • S sumit7034

      Hi I want to problematically determine if mysql is installed on my machine or not. Please help

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      I'd try WMI and look for the MySQL service.

      S 1 Reply Last reply
      0
      • B Bernhard Hiller

        I'd try WMI and look for the MySQL service.

        S Offline
        S Offline
        sumit7034
        wrote on last edited by
        #3

        How to check using wmi

        B 1 Reply Last reply
        0
        • S sumit7034

          Hi I want to problematically determine if mysql is installed on my machine or not. Please help

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          sumit7034 wrote:

          I want to problematically determine...

          really? :-D it could be installed but not running, so maybe it is better to check for a process, with a name that contains "mysql"; the exact name may depend on the implementation, my XAMPP package launches a "mysqld" process. See Process.GetProcessesByName() :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          1 Reply Last reply
          0
          • S sumit7034

            How to check using wmi

            B Offline
            B Offline
            Bernhard Hiller
            wrote on last edited by
            #5

            It's something like:

            System.Management.ManagementScope oMs = new System.Management.ManagementScope(@"\\localhost");
            oMs.Path.NamespacePath = @"root\cimv2";
            string query = "select * From Win32_Service Where Name Like \"%mysql%\"";
            System.Management.ObjectQuery oQuery = new System.Management.ObjectQuery(query);
            ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMs, oQuery);
            ManagementObjectCollection oReturnCollection = oSearcher.Get();
            foreach (ManagementObject oReturn in oReturnCollection)
            {
            foreach (PropertyData propertyData in oReturn.Properties)
            {
            txtResult.Text += string.Format("{0}: {1}\r\n", propertyData.Name, propertyData.Value);
            }
            }

            This writes all information available on all services containing "mysql" in their name into textbox "txtResult". Note also the "State" and "Started" properties.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups