{"id":20156171,"url":"https://github.com/dsccommunity/xmysql","last_synced_at":"2025-12-11T21:32:07.177Z","repository":{"id":30468253,"uuid":"34022239","full_name":"dsccommunity/xMySql","owner":"dsccommunity","description":null,"archived":false,"fork":false,"pushed_at":"2018-09-22T10:32:50.000Z","size":75,"stargazers_count":9,"open_issues_count":11,"forks_count":15,"subscribers_count":20,"default_branch":"dev","last_synced_at":"2025-04-09T22:40:06.933Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dsccommunity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-15T22:43:02.000Z","updated_at":"2024-09-01T23:10:45.000Z","dependencies_parsed_at":"2022-08-22T23:40:30.644Z","dependency_job_id":null,"html_url":"https://github.com/dsccommunity/xMySql","commit_stats":null,"previous_names":["powershell/xmysql"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/dsccommunity/xMySql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsccommunity%2FxMySql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsccommunity%2FxMySql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsccommunity%2FxMySql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsccommunity%2FxMySql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsccommunity","download_url":"https://codeload.github.com/dsccommunity/xMySql/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsccommunity%2FxMySql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274777167,"owners_count":25347644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T23:37:51.798Z","updated_at":"2025-12-11T21:32:07.081Z","avatar_url":"https://github.com/dsccommunity.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build status](https://ci.appveyor.com/api/projects/status/ji440gfk30kxn4ri/branch/master?svg=true)](https://ci.appveyor.com/project/PowerShell/xmysql/branch/master)\r\n\r\n# xMySql\r\n\r\nThe **xMySql** module contains the **xMySqlServer, xMySqlDatabase, xMySqlUser, xMySqlGrant, xMySqlProvision** DSC resources allowing you to setup and configure a MySQL servers, databases, users, and grants.\r\n\r\n\r\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\r\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\r\n\r\n## Contributing\r\nPlease check out common DSC Resources [contributing guidelines](https://github.com/PowerShell/DscResource.Kit/blob/master/CONTRIBUTING.md).\r\n\r\n\r\n## Resources\r\n\r\n* **xMySqlServer** configures MySQL servers\r\n* **xMySqlDatabase** configures MySQL databases.\r\n* **xMySqlUser** configures MySQL users.\r\n* **xMySqlGrant** configures MySQL grants.\r\n* **xMySqlProvison** is a composite resource that provisions a set of MySQL servers, databases, users, and permission grants using the other resources.\r\n\r\n### xMySqlServer\r\n\r\n* **ServiceName:** Provides the service name to use during setup of MySQL.\r\n* **Ensure**: Ensures that the server is Present or Absent.\r\n* **RootPassword**:  The root password that is used to install a MySQL server.\r\nNote: a PSCredential object is used to store the password securely.\r\nThe user name can be any non-zero length string, but it will be ignored.\r\n\r\n### xMySqlDatabase\r\n\r\n* **Name**: Name of the database to create.\r\n* **Ensure**: Ensures that the database is Present or Absent.\r\n* **ConnectionCredential:** The credential that is used to create the MySQL database.\r\n\r\n### xMySqlUser\r\n\r\n* **Name**: Name of the MySQL user to create or remove.\r\n* **Ensure**: Ensures that the user is Present or Absent.\r\n* **Credential**: Credential for the MySQL user.\r\n* **ConnectionCredential:** The credential that is used to create or remove the user.\r\n\r\n### xMySqlGrant\r\n\r\n* **UserName**: Name of MySQL user.\r\n* **DatabaseName**: MySQL database name to grant permissions.\r\n* **Ensure**: Ensure permission grant is Present or Absent\r\n* **PermissionType**: MySQL user permission type.\r\n* **ConnectionCredential**: The credential that is used to create the grant.\r\n\r\n### xMySqlProvision\r\n\r\n* **ServiceName**: Provides the service name to use during setup of MySQL.\r\n* **DownloadUri**: The URL/URI used for downloading the MySQL MSI.\r\n* **RootCredential**:The MySQL root credentials, user name and password.\r\n* **DatabaseName**: The MySQL database name.\r\n* **UserCredential**:The credentials, user name and password, for the MySQL user.\r\n\r\n\r\n## Versions\r\n\r\n### Unreleased\r\n\r\n* Changed to the default appveyor.yml template.\r\n* Activate the GitHub App Stale on the GitHub repository.\r\n* Added default template files .codecov.yml, .gitattributes, and .gitignore, and\r\n  .vscode folder.\r\n* Added new line to end of file for test files.\r\n\r\n### 2.1.0.0\r\n\r\n* Added import for local MSFT_xMySqlUtilities in Tests\r\n* Fixed a SQL syntax error for REVOKE in MSFT_xMySqlGrant\r\n\r\n### 2.0.0.0\r\n\r\n* NOTE: This contains breaking Changes\r\n* Updated all resources to contain unit tests\r\n* Modified schema on many resources to standardize naming\r\n* Fixed resources to removing hard coding of MySQL Version (Fixes #2)\r\n* Removed Debug Tracing of Passwords (Fixes #3)\r\n* Created standard library to reduce code redundancy\r\n\r\n### 1.1.0.0\r\n\r\n * Resolved attribute between *.psm1 and *.schema.mof files.\r\n * Fixed encoding\r\n\r\n### 1.0.0.0\r\n\r\n* Initial release with the following resources :\r\n    * xMySqlServer\r\n    * xMySqlDatabase\r\n    * xMySqlUser\r\n    * xMySqlGrant\r\n    * xMySqlProvision\r\n\r\n# Setup a MySQL server on a single node\r\n\r\nThis configuration will setup a MySQL server on a single node.\r\n\r\n```powershell\r\nConfiguration SQLInstanceInstallationConfiguration\r\n{\r\n    param\r\n    (\r\n        [parameter(Mandatory = $true)]\r\n        [ValidateNotNullOrEmpty()]\r\n        [String] $MySQLInstancePackagePath,\r\n        [parameter(Mandatory = $true)]\r\n        [ValidateNotNullOrEmpty()]\r\n        [String] $MySQLInstancePackageName\r\n    )\r\n\r\n    Import-DscResource -Module xMySql\r\n    node $AllNodes.NodeName\r\n    {\r\n\r\n        xPackage mySqlInstaller\r\n        {\r\n\r\n            Path = $MySQLInstancePackagePath\r\n            ProductId = $Node.PackageProductID\r\n            Name = $MySQLInstancePackageName\r\n        }\r\n\r\n        xMySqlServer MySQLInstance\r\n        {\r\n            Ensure = \"Present\"\r\n            RootPassword = $global:cred\r\n            ServiceName = \"MySQLServerInstanceName\"\r\n            DependsOn = \"[xPackage]mySqlInstaller\"\r\n        }\r\n    }\r\n}\r\n# Sample use (parameter values need to be changed according to your scenario):\r\n$global:pwd = ConvertTo-SecureString \"pass@word1\" -AsPlainText -Force\r\n$global:usrName = \"administrator\"\r\n$global:cred = New-Object -TypeName System.Management.Automation.PSCredential ($global:usrName,$global:pwd)\r\nSQLInstanceInstallationConfiguration `\r\n    -MySQLInstancePackagePath \"http://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-5.6.17.0.msi\" `\r\n    -MySQLInstancePackageName \"MySQL Installer\" -ConfigurationData .\\nodedata.psd1\r\n```\r\n\r\n### Setup a MySQL server database\r\n\r\nThis configuration will setup a MySQL server and create a database.\r\n\r\n```powershell\r\nConfiguration SQLInstanceAndDatabaseInstallationConfiguration\r\n{\r\n    param\r\n    (\r\n        [parameter(Mandatory = $true)]\r\n        [ValidateNotNullOrEmpty()]\r\n        [String] $MySQLInstancePackagePath,\r\n        [parameter(Mandatory = $true)]\r\n        [ValidateNotNullOrEmpty()]\r\n        [String] $MySQLInstancePackageName\r\n    )\r\n    Import-DscResource -Module xMySql\r\n\r\n    node $AllNodes.NodeName\r\n    {\r\n\r\n        xPackage mySqlInstaller\r\n        {\r\n\r\n            Path = $MySQLInstancePackagePath\r\n            ProductId = $Node.PackageProductID\r\n            Name = $MySQLInstancePackageName\r\n            Ensure = \"Present\"\r\n        }\r\n\r\n        xMySqlServer MySQLInstance\r\n        {\r\n            Ensure = \"Present\"\r\n            RootPassword= $global:cred\r\n            ServiceName = \"MySQLInstanceServiceName\"\r\n            DependsOn = \"[xPackage]mySqlInstaller\"\r\n        }\r\n        xMySqlDatabase MySQLDatabase\r\n        {\r\n            Ensure = \"Present\"\r\n            Name = \"TestDB\"\r\n            ConnectionCredential = $global:cred\r\n            DependsOn = \"[xMySqlInstance]MySQLInstance\"\r\n        }\r\n    }\r\n}\r\n# Sample use (parameter values need to be changed according to your scenario):\r\n$global:pwd = ConvertTo-SecureString \"pass@word1\" -AsPlainText -Force\r\n$global:usrName = \"administrator\"\r\n$global:cred = New-Object -TypeName System.Management.Automation.PSCredential ($global:usrName,$global:pwd)\r\nSQLInstanceAndDatabaseInstallationConfiguration `\r\n    -MySQLInstancePackagePath \"http://dev.mysql.com/get/Downloads/MySQLInstaller/mysql-installer-community-5.6.17.0.msi\" `\r\n    -MySQLInstancePackageName \"MySQL Installer\" -ConfigurationData .\\nodedata.psd1\r\n```\r\n\r\n### Setup a MySQL server user\r\n\r\nThis configuration will setup a MySQL user, assuming mySQL is installed on a local machine with root user $RootUser and root password $global:pwd.\r\n\r\n```\r\nConfiguration CreateMySQLUserConfiguration\r\n{\r\n    param\r\n    (\r\n        [parameter(Mandatory = $true)]\r\n        [ValidateNotNullOrEmpty()]\r\n        [String] $Name\r\n    )\r\n\r\n    Import-DscResource -Module xMySql\r\n    $mySQLUserCredential = New-Object -TypeName System.Management.Automation.PSCredential ($Name,$global:pwd)\r\n    node (\"localhost\")\r\n    {\r\n        xMySqlUser NewMySqlUser1\r\n        {\r\n            Name = $Name\r\n            Credential = $mySQLUserCredential\r\n            Ensure = \"Present\"\r\n            ConnectionCredential = $global:MySQLRootCredential\r\n\r\n        }\r\n    }\r\n}\r\n$global:pwd = ConvertTo-SecureString \"pass@word1\" -AsPlainText -Force\r\n$global:RootUser = \"root\"\r\n$global:MySQLRootCredential = New-Object -TypeName System.Management.Automation.PSCredential ($global:RootUser,$global:pwd)\r\n# Create localhost.mof\r\nCreateMySQLUserConfiguration -output \"$env:temp\\CreateMySQLUserConfiguration\"\r\n```\r\n\r\n### Setup a MySQL server grant\r\n\r\nThis configuration will grant full acesss to a given MySQL database for a given user.\r\nIt assumes that mySQL is installed on a local machine with root user $RootUser and root password $global:pwd.\r\n\r\n```powershell\r\nconfiguration MySQLGrantConfiguration\r\n{\r\n    param\r\n    (\r\n        [parameter(Mandatory = $true)]\r\n        [ValidateNotNullOrEmpty()]\r\n        [String] $UserName,\r\n        [parameter(Mandatory = $true)]\r\n        [ValidateNotNullOrEmpty()]\r\n        [String] $DatabaseName\r\n    )\r\n\r\n    Import-DscResource -Module xMySql\r\n\r\n    node (\"localhost\")\r\n    {\r\n        xMySqlGrant mySQLGrant\r\n        {\r\n            UserName = $UserName\r\n            DatabaseName = $DatabaseName\r\n            PermissionType = \"ALL PRIVILEGES\"\r\n            Ensure = \"Present\"\r\n            ConnectionCredential = $global:MySQLRootCredential\r\n\r\n        }\r\n    }\r\n}\r\n$global:pwd = ConvertTo-SecureString \"pass@word1\" -AsPlainText -Force\r\n$global:RootUser = \"root\"\r\n$global:MySQLRootCredential = New-Object -TypeName System.Management.Automation.PSCredential ($global:RootUser,$global:pwd)\r\n# Create localhost.mof\r\nCreateMySQLUserConfiguration -output \"$env:temp\\MySQLGrantConfiguration\"\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsccommunity%2Fxmysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsccommunity%2Fxmysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsccommunity%2Fxmysql/lists"}