Skip to content

Commit

Permalink
Add mysql8,mysql8.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mischabraam committed Oct 16, 2023
1 parent 877ee2f commit 59a3efd
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 9 deletions.
10 changes: 8 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ This project uses [laravel/valet](https://github.com/laravel/valet) as a depende
instructions of Laravel's Valet.

> Note: install [email protected] first before installing Valet+.
> You can do this with the following commands.
> ```shell
> brew install [email protected]
> brew link [email protected] --force
> brew services restart [email protected]
> ```
## Valet+ features
Expand All @@ -19,7 +25,7 @@ Here are a few key differences compared to the original Valet:
- Nginx config optimization
- PHP extensions (~~mcrypt~~, ~~intl~~, ~~opcache~~, yaml, apcu)
- MySQL ([email protected], mysql@8, mariadb)
- MySQL ([email protected], mysql@8.0, [email protected], mariadb)
- DB commands (list, create, drop, reset, (re)import, export, ~~open~~)
- Mailhog (on/off mode)
- Varnish (on/off mode)
Expand All @@ -36,7 +42,7 @@ Here are a few key differences compared to the original Valet:
### Changes vs Valet+ 2
- Use command `valet-plus` instead of `valet`. (for now)
- Use command `valet-plus` instead of `valet` (for now).
- Rename `.env.valet` to `.valet-env.php`.
- Use command `valet-plus elasticsearch|es use <version>` instead of `valet-plus use elasticsearch|es <version>`.
- Use `127.0.0.1` as Redis host instead of `/tmp/redis.sock`.
Expand Down
6 changes: 5 additions & 1 deletion cli/ValetPlus/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Mysql
const MYSQL_DATA_DIR = 'var/mysql';
const MYSQL_ROOT_PASSWORD = 'root';
const MYSQL_DEFAULT_VERSION = '[email protected]';
const MYSQL_SUPPORTED_VERSIONS = ['mysql@5.7', 'mysql', 'mariadb'];
const MYSQL_SUPPORTED_VERSIONS = ['mysql', '[email protected]', 'mysql@5.7', 'mariadb'];

/** @var Brew */
protected $brew;
Expand Down Expand Up @@ -212,6 +212,7 @@ public function setRootPassword($oldPwd = '', $newPwd = self::MYSQL_ROOT_PASSWOR
});
break;

case '[email protected]':
case 'mysql':
$retval = $this->query(
"ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '" . $newPwd . "';",
Expand Down Expand Up @@ -440,6 +441,9 @@ protected function getDatabases()
protected function query($query, $escape = true, $withoutRootPwd = false)
{
$link = $this->getConnection($withoutRootPwd);
if ($link === false) {
return false;
}

$query = $escape ? $this->escape($query) : $query;

Expand Down
37 changes: 37 additions & 0 deletions cli/stubs/mysql/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[mysqld]
bind-address=127.0.0.1
mysqlx-bind-address=127.0.0.1
default_authentication_plugin=mysql_native_password

[client]
user=root
password=root
host=localhost

[mysqldump]
column-statistics=0

[mysqld]
sql_mode="NO_ENGINE_SUBSTITUTION"
innodb_file_per_table=OFF
open_files_limit=262144
log-error=VALET_HOME_PATH/Log/mysql.log
local_infile=ON
secure_file_priv=""
max_allowed_packet=1073741824
max_connections=100000
key_buffer_size=1024M
innodb_buffer_pool_size=1024M
table_open_cache=4096
innodb_buffer_pool_instances=24
myisam_sort_buffer_size=1024M
innodb_sort_buffer_size=1024M
sort_buffer_size=1024M
innodb_flush_log_at_trx_commit=0
innodb_log_file_size=25M
interactive_timeout=3600
max_connect_errors=1000000
thread_cache_size=1024

[mysqld_safe]
open_files_limit=262144
17 changes: 11 additions & 6 deletions cli/valet.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@
*/
$cmd = $app->get('install');
$app
->command('install', function (InputInterface $input, OutputInterface $output, $withMariadb, $withMysql8, $withBinary) use ($cmd) {
if ($withMariadb && $withMysql8) {
throw new Exception('Cannot install Valet+ with both MariaDB and Mysql8, please pick one.');
->command('install', function (InputInterface $input, OutputInterface $output, $withMariadb, $withMysql80, $withMysql81, $withBinary) use ($cmd) {
$types = $withMariadb + $withMysql80 + $withMysql81;
if ($types > 1) {
throw new Exception('Cannot install Valet+ with multiple DBMS, please pick one.');
}
$mySqlVersion = $withMariadb ? 'mariadb' : '[email protected]';
$mySqlVersion = $withMysql8 ? 'mysql' : $mySqlVersion;
$mySqlVersion = $withMysql81 ? 'mysql' : $mySqlVersion;
$mySqlVersion = $withMysql80 ? '[email protected]' : $mySqlVersion;

// Add custom options to original command to fake 'm.
$cmd->addOption('with-mysql-8', null, InputOption::VALUE_NONE)
$cmd->addOption('with-mysql80', null, InputOption::VALUE_NONE)
->addOption('with-mysql81', null, InputOption::VALUE_NONE)
->addOption('with-mariadb', null, InputOption::VALUE_NONE)
->addOption('with-binary', 'b', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL);
// Run original command.
Expand All @@ -66,13 +69,15 @@
info("\nValet+ installed successfully!");
})
->descriptions('Install the Valet services')
->addOption('with-mysql-8', null, InputOption::VALUE_NONE, "Install with MySQL 8")
->addOption('with-mysql80', null, InputOption::VALUE_NONE, "Install with MySQL 8.0")
->addOption('with-mysql81', null, InputOption::VALUE_NONE, "Install with MySQL 8.1")
->addOption('with-mariadb', null, InputOption::VALUE_NONE, "Install with MariaDB")
->addOption(
'with-binary',
'b',
InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL,
"Install with binary, by default all binaries are installed\n" .
"Use `-b [binary] -b [binary]` to install multiple binaries you wish\n" .
"Supported binaries: " . implode(', ', Binary::getSupported()) . "\n"
);

Expand Down

0 comments on commit 59a3efd

Please sign in to comment.