iroddis / asdf-mysql

A MySQL Plugin for asdf
GNU General Public License v2.0
19 stars 8 forks source link

Install issues #33

Closed pboling closed 1 year ago

pboling commented 1 year ago

The command in the README reports that it is deprecated and to use a different command instead. When I tried that I got a warning to also add --explicit_defaults_for_timestamp, so I did that as well.

Now I am getting some additional warnings and errors. The error-message file error is clearly using the wrong path. My $MYSQL_DATA_DIR is an absolute path, in my home directory.

Additionally, the root password it sets randomly on the last line does not actually work. :/

$ mysqld --initialize --datadir=$MYSQL_DATA_DIR --explicit_defaults_for_timestamp
2023-08-03T17:45:13.003202Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2023-08-03T17:45:13.004712Z 0 [Warning] Setting lower_case_table_names=2 because file system for /Users/pboling/src/apps/vc_mysql/data/ is case insensitive
2023-08-03T17:45:13.120470Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-08-03T17:45:13.148880Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-08-03T17:45:13.207179Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7fa9b71e-3225-11ee-bd78-fbf4d6511573.
2023-08-03T17:45:13.236129Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-08-03T17:45:13.650817Z 0 [Warning] CA certificate ca.pem is self signed.
2023-08-03T17:45:13.872757Z 1 [Note] A temporary password is generated for root@localhost: gxcHsZ78e<#s
iroddis commented 1 year ago

Hi @pboling . I've adjusted the install commands. Since the move to dbdeployer, the entire DATADIR rigmarole isn't needed. If you're installing MySQL 8 you can just follow the new instructions:

asdf install mysql latest
asdf global mysql latest
mysqld --initialize      # Root password will be generated here
mysqld_safe              # Start the daemon
pboling commented 1 year ago

I am installing the latest MySQL 5.7 actually. Hopefully we can switch to 8 soon.

Will the instructions be the same for 5.7?

iroddis commented 1 year ago

Slightly different:

export DATADIR=/path/to/database
mysqld --initialize --datadir=$DATADIR

# Start mysql server as below
mysqld_safe --datadir=$DATADIR

# Secure the installation
mysql_secure_installation
pboling commented 1 year ago

Any idea how to fix the error-message file missing problem?

2023-08-03T18:43:33.679467Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
pboling commented 1 year ago

I can see that the files are in a very reasonable place, but MySQL is not using the asdf install:

$ find /Users/pboling/.asdf/installs/mysql/5.7.31/ -name errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/bulgarian/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/dutch/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/korean/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/czech/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/serbian/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/japanese/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/german/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/estonian/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/hungarian/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/slovak/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/romanian/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/norwegian-ny/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/russian/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/italian/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/english/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/greek/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/norwegian/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/portuguese/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/danish/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/polish/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/french/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/swedish/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/spanish/errmsg.sys
/Users/pboling/.asdf/installs/mysql/5.7.31//share/ukrainian/errmsg.sys
pboling commented 1 year ago

Seems like asdf should be able to set paths in such a way as to configure lc-messages-dir per asdf-installed version of MySQL.

pboling commented 1 year ago

It looks like the defaults are not setup to use the asdf install.

$ mysqld --verbose --help | grep /usr/local/mysql
2023-08-03T22:12:28.141311Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
basedir                                                      /usr/local/mysql/
character-sets-dir                                           /usr/local/mysql/share/charsets/
datadir                                                      /usr/local/mysql/data/
general-log-file                                             /usr/local/mysql/data/SpaceSocks.log
language                                                     /usr/local/mysql/share/
lc-messages-dir                                              /usr/local/mysql/share/
pid-file                                                     /usr/local/mysql/data/SpaceSocks.pid
plugin-dir                                                   /usr/local/mysql/lib/plugin/
slow-query-log-file                                          /usr/local/mysql/data/SpaceSocks-slow.log
iroddis commented 1 year ago

It looks like you may not be using the asdf install. Do you have MySQL installed on the system as well as via asdf?

Did you run the “asdf global mysql X.X.X” command before running the mysqld command?

What OS are you using?

On Thu, Aug 3, 2023, at 19:13, Peter Boling wrote:

It looks like the defaults are not setup to use the asdf install.

$ mysqld --verbose --help | grep /usr/local/mysql 2023-08-03T22:12:28.141311Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive. /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf basedir /usr/local/mysql/ character-sets-dir /usr/local/mysql/share/charsets/ datadir /usr/local/mysql/data/ general-log-file /usr/local/mysql/data/SpaceSocks.log language /usr/local/mysql/share/ lc-messages-dir /usr/local/mysql/share/ pid-file /usr/local/mysql/data/SpaceSocks.pid plugin-dir /usr/local/mysql/lib/plugin/ slow-query-log-file /usr/local/mysql/data/SpaceSocks-slow.log

— Reply to this email directly, view it on GitHub https://github.com/iroddis/asdf-mysql/issues/33#issuecomment-1664707863, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHMVVSJBAMP6DD2LIFAKAUDXTQO7PANCNFSM6AAAAAA3DD2X4Y. You are receiving this because you commented.Message ID: @.***>

pboling commented 1 year ago

Do you have MySQL installed on the system as well as via asdf?

I used to have mysql installed via homebrew, but I have uninstalled it. There is some vestigial cruft that I'm removing as I find it...

Did you run the “asdf global mysql X.X.X” command before running the mysqld command?

Yes.

What OS are you using?

I am on MacOS 13.5.

Does asdf have a --prefix command like brew does, so we can find the "install directory" of a particular version targeted program?

Something like asdf --prefix mysql?

pboling commented 1 year ago
export MYSQL_DATA_DIR=/Users/pboling/src/apps/vc_mysql/data/
export MYSQL_BASE_DIR=/Users/pboling/.asdf/installs/mysql/5.7.31/

# Cleanup from previous attempts:
rm -rf $MYSQL_DATA_DIR && mkdir -p $MYSQL_DATA_DIR

mysqld --initialize-insecure --datadir=$MYSQL_DATA_DIR --basedir=$MYSQL_BASE_DIR --explicit_defaults_for_timestamp
2023-08-03T22:30:39.068090Z 0 [Warning] Setting lower_case_table_names=2 because file system for /Users/pboling/src/apps/vc_mysql/data/ is case insensitive
2023-08-03T22:30:39.185560Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-08-03T22:30:39.205060Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-08-03T22:30:39.262504Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5f965f40-324d-11ee-bd0e-c67a0fde2f4c.
2023-08-03T22:30:39.291930Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-08-03T22:30:39.638157Z 0 [Warning] CA certificate ca.pem is self signed.
2023-08-03T22:30:40.387761Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

This is how far I have gotten, which is past all errors, but not portable at all, so I can't switch between versions easily. Also the process exits without explanation.

pboling commented 1 year ago

When I use mysqld_safe:

$ mysqld_safe --initialize-insecure --datadir=$MYSQL_DATA_DIR --basedir=$MYSQL_BASE_DIR --explicit_defaults_for_timestamp
2023-08-03T22:32:06.6NZ mysqld_safe Logging to '/Users/pboling/src/apps/vc_mysql/data/SpaceSocks.local.err'.
2023-08-03T22:32:06.6NZ mysqld_safe Starting mysqld daemon with databases from /Users/pboling/src/apps/vc_mysql/data
2023-08-03T22:32:06.6NZ mysqld_safe mysqld from pid file /Users/pboling/src/apps/vc_mysql/data/SpaceSocks.local.pid ended

I do get an explanation in the referenced logfile, but it doesn't make any sense:

$ cat /Users/pboling/src/apps/vc_mysql/data/SpaceSocks.local.err
2023-08-03T22:37:16.6NZ mysqld_safe Logging to '/Users/pboling/src/apps/vc_mysql/data/SpaceSocks.local.err'.
2023-08-03T22:37:16.6NZ mysqld_safe Starting mysqld daemon with databases from /Users/pboling/src/apps/vc_mysql/data
2023-08-03T22:37:16.412215Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2023-08-03T22:37:16.412903Z 0 [ERROR] Aborting

2023-08-03T22:37:16.6NZ mysqld_safe mysqld from pid file /Users/pboling/src/apps/vc_mysql/data/SpaceSocks.local.pid ended

It doesn't make sense because I literally just rm -rf /Users/pboling/src/apps/vc_mysql/data && mkdir -p /Users/pboling/src/apps/vc_mysql/data before running the command.

iroddis commented 1 year ago

Does asdf have a --prefix command like brew does, so we can find the "install directory" of a particular version targeted program?

It does, you can run asdf which mysqld_safe to find the binary that asdf resolves to. You may also want to run just the plain which mysqld_safe as well to make sure that you're picking up the asdf version.

Can you try this:

rm -rf /Users/pboling/src/apps/vc_mysql/data
mysqld --initialize --datadir /Users/pboling/src/apps/vc_mysql/data --explicit_defaults_for_timestamp

mysqld will create any needed directories (mysqld_safe will not).

pboling commented 1 year ago

Sure. I already reinstalled MySQL 5.7 with brew so that I could uninstall & zap it.

$ brew uninstall --zap mysql@5.7
Uninstalling /usr/local/Cellar/mysql@5.7/5.7.43... (321 files, 234.6MB)

I tried the command you suggested, and it crashed.

This is the command with the fewest errors, but still crashes, and it is now using the asdf which mysql:

$ mysqld --initialize-insecure --datadir=/Users/pboling/src/apps/vc_mysql/data --basedir=$(asdf which mysql)/../../ --explicit_defaults_for_timestamp

2023-08-04T05:50:25.440902Z 0 [Warning] Setting lower_case_table_names=2 because file system for /Users/pboling/src/apps/vc_mysql/data/ is case insensitive
2023-08-04T05:50:25.957080Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-08-04T05:50:26.034714Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-08-04T05:50:26.091808Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: cf5cfec8-328a-11ee-a50c-0ba109464588.
2023-08-04T05:50:26.126722Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-08-04T05:50:26.693261Z 0 [Warning] CA certificate ca.pem is self signed.
2023-08-04T05:50:27.141715Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
iroddis commented 1 year ago

Try again with just --initialize, not --initialize-insecure.

On an up-to-date mac, I was able to install it as:

~ asdf install mysql 5.7.31
Successfully installed MySQL 5.7.31
To initialize a new database:
  asdf global mysql 5.7.31
  mysql_install_db --datadir=$DATADIR
        or
  mysqld --initialize --datadir=$DATADIR  # Record root password
  # Start mysql server as below
  mysqld_safe --datadir=$DATADIR
  mysql_secure_installation
To stop the server:
  mysqladmin -u root shutdown
~ export DATADIR=${HOME}/tmp/mysql_5.7
~ asdf global mysql 5.7.31                                                                                          2 ↵
~ mysqld --initialize --datadir=$DATADIR
2023-08-04T10:15:53.995527Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-08-04T10:15:53.995747Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2023-08-04T10:15:53.996412Z 0 [Warning] Setting lower_case_table_names=2 because file system for /Users/user/tmp/mysql_5.7/ is case insensitive
2023-08-04T10:15:54.059480Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-08-04T10:15:54.067512Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-08-04T10:15:54.124505Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e535e834-32af-11ee-a454-09db31635eae.
2023-08-04T10:15:54.132061Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-08-04T10:15:54.525404Z 0 [Warning] CA certificate ca.pem is self signed.
2023-08-04T10:15:54.607688Z 1 [Note] A temporary password is generated for root@localhost: e_MzBtwmb2f2
~ mysqld_safe --datadir=$DATADIR
2023-08-04T10:16:03.6NZ mysqld_safe Logging to '/Users/user/tmp/mysql_5.7/athena.err'.
2023-08-04T10:16:03.6NZ mysqld_safe Starting mysqld daemon with databases from /Users/user/tmp/mysql_5.7

# In another terminal, using the temporary root password used above
~ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.31

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
iroddis commented 1 year ago

Going to close this for now, hopefully you got it figured out.

pboling commented 1 year ago

Thanks for your help! I am trying to find time to work on it in between other things. It looks like worst case scenario I need to start with a fresh MacOS install. The one I have has been migrated for like 10 years probably.