server icon indicating copy to clipboard operation
server copied to clipboard

Self-Hosted V2 Getting Error: Access denied for user 'std_notes_user'

Open 501st-alpha1 opened this issue 1 year ago • 1 comments

I'm trying to set up a self-hosted Standard Notes instance, but keep getting this access denied error. (Well, I'm actually trying to do a migration from a legacy self-hosted install, but I scrapped everything and started from scratch as a test, and am still getting this error.)

I followed the steps exactly:

  1. Starting in an empty directory.
  2. touch .env
    curl https://raw.githubusercontent.com/standardnotes/server/main/.env.sample > .env
    
  3. Set values in KEYS section using values generated by openssl rand -hex 32.
  4. curl https://raw.githubusercontent.com/standardnotes/server/main/docker/localstack_bootstrap.sh > localstack_bootstrap.sh
    chmod +x localstack_bootstrap.sh
    
  5. curl https://raw.githubusercontent.com/standardnotes/server/main/docker-compose.example.yml > docker-compose.yml
    
  6. Generate DB password with openssl rand -hex 12, save to DB_PASSWORD in .env and both MYSQL_ROOT_PASSWORD and MYSQL_PASSWORD in docker-compose.yml.
  7. (I had to add e.g. version: '3.5' to my docker-compose.yml, possibly because I'm on an old version of Compose.)
  8. docker-compose pull and docker-compose up.

On docker-compose up, services begin starting up and it runs for a bit, but then eventually starts looping on messages like this:

server_self_hosted | 2024-02-23 03:27:15,028 WARN exited: revisions (exit status 1; not expected)
db_self_hosted | 2024-02-23T03:27:15.197167Z 9 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
server_self_hosted | 2024-02-23 03:27:15,247 INFO spawned: 'revisions' with pid 210
server_self_hosted | 2024-02-23 03:27:15,721 WARN exited: syncing-server-worker (exit status 1; not expected)
server_self_hosted | 2024-02-23 03:27:15,777 INFO spawned: 'syncing-server-worker' with pid 227
server_self_hosted | 2024-02-23 03:27:16,300 INFO success: revisions entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
server_self_hosted | 2024-02-23 03:27:16,788 INFO success: syncing-server-worker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
server_self_hosted | 2024-02-23 03:27:16,788 WARN exited: auth (exit status 1; not expected)
server_self_hosted | 2024-02-23 03:27:16,802 INFO spawned: 'auth' with pid 243
server_self_hosted | 2024-02-23 03:27:17,835 INFO success: auth entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
db_self_hosted | 2024-02-23T03:27:23.836363Z 10 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
server_self_hosted | 2024-02-23 03:27:24,743 WARN exited: syncing-server-worker (exit status 1; not expected)
server_self_hosted | 2024-02-23 03:27:24,746 INFO spawned: 'syncing-server-worker' with pid 270
server_self_hosted | 2024-02-23 03:27:25,745 INFO success: syncing-server-worker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
server_self_hosted | 2024-02-23 03:27:27,086 WARN exited: auth (exit status 1; not expected)
server_self_hosted | 2024-02-23 03:27:27,114 INFO spawned: 'auth' with pid 286
server_self_hosted | 2024-02-23 03:27:28,126 INFO success: auth entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
server_self_hosted | 2024-02-23 03:27:32,279 WARN exited: syncing-server-worker (exit status 1; not expected)
server_self_hosted | 2024-02-23 03:27:32,288 INFO spawned: 'syncing-server-worker' with pid 306
server_self_hosted | 2024-02-23 03:27:33,326 INFO success: syncing-server-worker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
server_self_hosted | 2024-02-23 03:27:35,385 WARN exited: auth (exit status 1; not expected)
server_self_hosted | 2024-02-23 03:27:35,439 INFO spawned: 'auth' with pid 322
server_self_hosted | 2024-02-23 03:27:36,470 INFO success: auth entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
db_self_hosted | 2024-02-23T03:27:39.531700Z 11 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
db_self_hosted | 2024-02-23T03:27:43.213380Z 12 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
server_self_hosted | 2024-02-23 03:27:59,863 WARN exited: auth-worker (exit status 1; not expected)
server_self_hosted | 2024-02-23 03:27:59,871 INFO spawned: 'auth-worker' with pid 388
server_self_hosted | 2024-02-23 03:28:00,897 INFO success: auth-worker entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

Okay, a couple services keep dying, let me look at the logs. Picking one at random, auth.err, I see this message looping:

localhost (127.0.0.1:3101) open
/opt/server/.yarn/cache/mysql2-npm-3.3.3-d2fe8cf512-4bf7ace8f1.zip/node_modules/mysql2/lib/packets/packet.js:728
    const err = new Error(message);
                ^

Error: Access denied for user 'std_notes_user'@'172.26.0.9' (using password: YES)
    at Packet.asError (/opt/server/.yarn/cache/mysql2-npm-3.3.3-d2fe8cf512-4bf7ace8f1.zip/node_modules/mysql2/lib/packets/packet.js:728:17)
    at ClientHandshake.execute (/opt/server/.yarn/cache/mysql2-npm-3.3.3-d2fe8cf512-4bf7ace8f1.zip/node_modules/mysql2/lib/commands/command.js:29:26)
    at PoolConnection.handlePacket (/opt/server/.yarn/cache/mysql2-npm-3.3.3-d2fe8cf512-4bf7ace8f1.zip/node_modules/mysql2/lib/connection.js:490:32)
    at PacketParser.onPacket (/opt/server/.yarn/cache/mysql2-npm-3.3.3-d2fe8cf512-4bf7ace8f1.zip/node_modules/mysql2/lib/connection.js:95:12)
    at PacketParser.executeStart (/opt/server/.yarn/cache/mysql2-npm-3.3.3-d2fe8cf512-4bf7ace8f1.zip/node_modules/mysql2/lib/packet_parser.js:75:16)
    at Socket.<anonymous> (/opt/server/.yarn/cache/mysql2-npm-3.3.3-d2fe8cf512-4bf7ace8f1.zip/node_modules/mysql2/lib/connection.js:102:25)
    at Socket.emit (node:events:514:28)
    at addChunk (node:internal/streams/readable:545:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)
    at Readable.push (node:internal/streams/readable:375:5) {
  code: 'ER_ACCESS_DENIED_ERROR',
  errno: 1045,
  sqlState: '28000',
  sqlMessage: "Access denied for user 'std_notes_user'@'172.26.0.9' (using password: YES)",
  sql: undefined
}

Node.js v20.10.0

This doesn't make sense, because I've double-triple-checked that DB_PASSWORD matches MYSQL_ROOT_PASSWORD and MYSQL_PASSWORD, so it can't be the same problem as #507.

I even verified that the database password was set correctly, by connecting to the DB container:

docker-compose exec db sh

then connecting to MySQL:

mysql -u std_notes_user -p

and entering the password, and that works.

What else could be causing this, or what can I do to try to troubleshoot further?

501st-alpha1 avatar Feb 23 '24 04:02 501st-alpha1

I faced the very same issue just like you described.

Finally what did the trick to me was removing the docker projects mysql directory and to recreate:

rm -rf ./data/mysql mkdir data/mysql

After that the SyncServer ramped up without errors

ingelumer avatar Feb 20 '25 06:02 ingelumer