mirromutth/mysql-action

Database is not created

Opened this issue · 5 comments

Hello,

I am trying to use your action, but the database isn't created.
Is use the following config:

      - uses: mirromutth/mysql-action@v1.1
        with:
          host port: 3800 # Optional, default value is 3306. The port of host
          container port: 3307 # Optional, default value is 3306. The port of container
          character set server: 'utf8' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
          collation server: 'utf8_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld
          mysql version: '8.0' # Optional, default value is "latest". The version of the MySQL
          mysql database: 'test' # Optional, default value is "test". The specified database which will be create
          mysql root password: 'root' # Required if "mysql user" is empty, default is empty. The root superuser password
          mysql user: 'root' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Of course you can use secrets, too
          mysql password: 'root' # Required if "mysql user" exists. The password for the "mysql user"

I get the following error further in the process:

SQLSTATE[HY000] [1049] Unknown database 'test' (SQL: select * from information_schema.tables where table_schema = test and table_name = system_models and table_type = 'BASE TABLE')

Any idea?

J4Wx commented

I'm having this same issue.

SQLSTATE[HY000] [1049] Unknown database '***' (SQL: selec t * from information_schema.tables where table_schema = *** and table_name = migrations and table_type = 'BASE TABLE')

Hi there, thanks for your report.

It is work to me, see https://github.com/mirromutth/r2dbc-mysql/blob/master/.github/workflows/build.yml

And, please keep mysql user empty if you have defined mysql root password. The mysql user option will create a superuser for the specified database, but it is not root superuser. Of course this is not the cause of this problem.

I will try create test cases to reproduce this scene.

@J4Wx @fridzema

I try create test cases for this problem but I can not reproduce it. What have I missed? See https://github.com/mirromutth/mysql-action/blob/master/.github/workflows/test.yml and https://github.com/mirromutth/mysql-action/blob/master/test

Thanks for your time

I am experiencing the same issue

your test cases do not include test the databases created

To reproduce

      - name: Shutdown Default Ubuntu MySQL (SUDO)
        run: sudo service mysql stop
      - name: Install MySQL
        uses: mirromutth/mysql-action@v1.1
        with:
          host port: 3306
          container port: 3306
          mysql version: '8.0'
          mysql database: 'my_db'  <--- default db to initalize
          mysql user: root
          mysql password: root
          
      - name: Start MySQL
        run: sudo service mysql start
      - name: Verify MySQL
        run: mysql --user=root --password=root
      - name: List existing SQL databases
        run: mysql --user=root --password=root --execute="show databases;" <--- my_db is not shown

my_db is not shown

Database
information_schema
mysql
performance_schema
sys

I had the same issue, problem is that for some reason, local mysql is still running (or some other version).
Run this instead:
mysql -h 127.0.0.1 --user=root --password=root --execute="show databases;"
and your db should be there.