<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # Using MySQL > 原文:[https://docs.gitlab.com/ee/ci/services/mysql.html](https://docs.gitlab.com/ee/ci/services/mysql.html) * [Use MySQL with the Docker executor](#use-mysql-with-the-docker-executor) * [Use MySQL with the Shell executor](#use-mysql-with-the-shell-executor) * [Example project](#example-project) # Using MySQL[](#using-mysql "Permalink") 由于許多應用程序都依賴 MySQL 作為其數據庫,因此最終需要它才能運行測試. 下面將指導您如何使用 GitLab Runner 的 Docker 和 Shell 執行程序執行此操作. ## Use MySQL with the Docker executor[](#use-mysql-with-the-docker-executor "Permalink") 如果您將[GitLab Runner](../runners/README.html)與 Docker 執行程序一起使用,則基本上已經完成了所有設置. First, in your `.gitlab-ci.yml` add: ``` services: - mysql:latest variables: # Configure mysql environment variables (https://hub.docker.com/_/mysql/) MYSQL_DATABASE: "<your_mysql_database>" MYSQL_ROOT_PASSWORD: "<your_mysql_password>" ``` **注意:**無法在 GitLab UI 中設置`MYSQL_DATABASE`和`MYSQL_ROOT_PASSWORD`變量. 要設置它們,請將它們分配給[UI 中](../variables/README.html#create-a-custom-variable-in-the-ui)的變量,然后將該變量分配給`.gitlab-ci.yml`的`MYSQL_DATABASE`和`MYSQL_ROOT_PASSWORD`變量. 然后將您的應用程序配置為使用數據庫,例如: ``` Host: mysql User: root Password: <your_mysql_password> Database: <your_mysql_database> ``` 如果您想知道為什么我們對`Host`使用`mysql` ,請閱讀[如何將服務鏈接到作業的更多信息](../docker/using_docker_images.html#how-services-are-linked-to-the-job) . 您還可以使用[Docker Hub](https://hub.docker.com/_/mysql/)上可用的任何其他 Docker 映像. 例如,要使用 MySQL 5.5,服務將變為`mysql:5.5` . `mysql`映像可以接受一些環境變量. 有關更多詳細信息,請參閱[Docker Hub](https://hub.docker.com/_/mysql/)上的文檔. ## Use MySQL with the Shell executor[](#use-mysql-with-the-shell-executor "Permalink") 您還可以在手動配置的服務器上使用 MySQL,該服務器通過 Shell 執行程序使用 GitLab Runner. 首先安裝 MySQL 服務器: ``` sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev ``` 選擇一個 MySQL 根密碼(可以是任何密碼),并在詢問時鍵入兩次. *注意:作為一項安全措施,您可以運行`mysql_secure_installation`刪除匿名用戶,刪除測試數據庫并以 root 用戶禁用遠程登錄.* 下一步是創建用戶,因此以 root 用戶身份登錄 MySQL: ``` mysql -u root -p ``` 然后創建一個將由您的應用程序使用的用戶(在我們的示例中為`runner` ). 將以下命令中的`$password`更改`$password`真實的強密碼. *注意:請勿鍵入`mysql>` ,這是 MySQL 提示符的一部分.* ``` mysql> CREATE USER 'runner'@'localhost' IDENTIFIED BY '$password'; ``` 創建數據庫: ``` mysql> CREATE DATABASE IF NOT EXISTS `<your_mysql_database>` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; ``` 授予對數據庫的必要權限: ``` mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES ON `<your_mysql_database>`.* TO 'runner'@'localhost'; ``` 如果一切順利,您現在可以退出數據庫會話: ``` mysql> \q ``` 現在,嘗試連接到新創建的數據庫以檢查一切是否就緒: ``` mysql -u runner -p -D <your_mysql_database> ``` 最后,配置您的應用程序以使用數據庫,例如: ``` Host: localhost User: runner Password: $password Database: <your_mysql_database> ``` ## Example project[](#example-project "Permalink") 為了方便起見,我們使用公共可[共享的](../runners/README.html)運行程序在[GitLab.com](https://gitlab.com)上運行了一個[MySQL 示例項目](https://gitlab.com/gitlab-examples/mysql) . 想要破解嗎? 只需對其進行分叉,提交并推送您的更改. 稍后,公共跑步者將選擇更改并開始工作.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看