Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to set the database collation and charset on creation #54

Open
edwardjosephbennett opened this issue Jan 23, 2019 · 3 comments
Open

Comments

@edwardjosephbennett
Copy link

Hi,

Is it possible to set the Database Collation and Database Charset when running wp valet new site?

I have been tinkering around with this and valet and find the setup fantastically useful, although this issue has been bugging me for a while.

At the minute when running the new site command, a database gets created with the following collation:
screenshot 2019-01-23 at 15 13 23

I have a plugin that creates database tables, which throws up errors on activation regarding and incorrect collation type. See an example of stack trace below:

Fatal error: Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8mb4_unicode_520_ci' is not valid for CHARACTER SET 'utf8' in .../wp-content/plugins/.../vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:77
Stack trace:
#0 .../wp-content/plugins/.../vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(77): PDO->prepare('set names 'utf8...', Array)
#1 .../wp-content/plugins/.../vendor/illuminate/database/Connectors/MySqlConnector.php(56): Doctrine\DBAL\Driver\PDOConnection->prepare('set names 'utf8...')
#2 .../wp-content/plugins/.../vendor/illuminate/database/Connectors/MySqlConnector.php(30): Illuminate\Database\Connectors\MySqlConnector->configureEncoding(Object(Doctrine\DBAL\Driver\PDOConnection), Array)

The issue I think sits around the either the plugin trying to set names 'utf8...' or the original collation being set with the 520 part is wrong.

Current MySQL Version is: Ver 8.0.13 for osx10.14 on x86_64 (Homebrew)

Any help on how this issue may be worked around either from WP-CLI Valets point of view or WP-CLI itself is appreciated.

Thanks,
Ed

@aaemnnosttv
Copy link
Owner

Hey there 👋

Currently the valet new command does not offer an option to provide the db charset or collation.

What you can do however, is add (temporarily?) these as defaults in your wp-cli config file like so:

core config:
  dbcharset: yourcharset
  dbcollate: yourcollation

Let me know if this does it for you!

@neilgee
Copy link

neilgee commented Jun 10, 2024

Trying to use core config for the charset but I need to mix it with config create - can I use both in the same file?, as now where I position it makes the other not be set

  admin_user: admin
  admin_password: "password"
  admin_email: [email protected]
  locale: en_AU
  # Subcommand defaults (e.g. `wp config create`)
config create:
    dbuser: root
    dbpass: 
    extra-php: |
        define( 'WP_DEBUG', true );
        define( 'WP_DEBUG_LOG', true );
        define( 'WP_DEBUG_DISPLAY', true );
        @ini_set( 'display_errors', 0 );
        define( 'WP_POST_REVISIONS', 7 );
core config:
    dbcharset: utf8mb4

@neilgee
Copy link

neilgee commented Jun 10, 2024

Actually works if I include it in config create

  admin_password: "password"
  admin_email: [email protected]
  locale: en_AU
  # Subcommand defaults (e.g. `wp config create`)
config create:
    dbuser: root
    dbpass: 
    dbcharset: utf8mb4
    extra-php: |
        define( 'WP_DEBUG', true );
        define( 'WP_DEBUG_LOG', true );
        define( 'WP_DEBUG_DISPLAY', true );
        @ini_set( 'display_errors', 0 );
        define( 'WP_POST_REVISIONS', 7 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants