Error 1045 28000 access denied for user root localhost using password yes docker

I have a docker-compose file and a Dockerfile. MySQL is installed properly. I have set MYSQL_ROOT_PASSWORD. But when trying to access mysql db, getting the error - Access denied. I have read the ot...

I have a docker-compose file and a Dockerfile. MySQL is installed properly. I have set MYSQL_ROOT_PASSWORD. But when trying to access mysql db, getting the error — Access denied. I have read the other threads of this site, but couldn’t get that much help. :(

Here is my docker-compose file:

version: '3'

volumes:
        db_data: {}

services:
    db:
        build:
            context: .
            dockerfile: ./db/Dockerfile
            args:
                - database=iTel
                - password=123
        image: db_image
        volumes:
            - db_data:/var/lib/mysql
        ports:
            - "3306:3306"

and Dockerfile:

FROM mysql:5.7.15

ARG database
ARG password

RUN echo ${database}
RUN echo ${password}

MAINTAINER me
ENV MYSQL_DATABASE=${database} 
    MYSQL_ROOT_PASSWORD=${password}
ADD ./db/database100.sql /docker-entrypoint-initdb.d
EXPOSE 3306

Here are logs for build:

docker-compose up -d

Building db
Step 1/9 : FROM mysql:5.7.15
5.7.15: Pulling from library/mysql
6a5a5368e0c2: Pull complete
0689904e86f0: Pull complete
486087a8071d: Pull complete
3eff318f6785: Pull complete
3df41d8a4cfb: Pull complete
1b4a00485931: Pull complete
0bab0b2c2630: Pull complete
264fc9ce512d: Pull complete
e0181dcdbbe8: Pull complete
53b082fa47c7: Pull complete
e5cf4fe00c4c: Pull complete
Digest: sha256:966490bda4576655dc940923c4883db68cca0b3607920be5efff7514e0379aa7
Status: Downloaded newer image for mysql:5.7.15
 ---> 18f13d72f7f0
Step 2/9 : ARG database
 ---> Running in 62819f9fc38b
Removing intermediate container 62819f9fc38b
 ---> 863fd3212046
Step 3/9 : ARG password
 ---> Running in ea9d36c1a954
Removing intermediate container ea9d36c1a954
 ---> 056100b1d5eb
Step 4/9 : RUN echo ${database}
 ---> Running in 941bd2f4fc58
iTel
Removing intermediate container 941bd2f4fc58
 ---> 7b2b48e7bd8c
Step 5/9 : RUN echo ${password}
 ---> Running in 9cb80396bb62
123
Removing intermediate container 9cb80396bb62
 ---> 155d184c78ba
Step 6/9 : MAINTAINER me
 ---> Running in 8e3b3b53ce7b
Removing intermediate container 8e3b3b53ce7b
 ---> 9a7617a24800
Step 7/9 : ENV MYSQL_DATABASE=${database}     MYSQL_ROOT_PASSWORD=${password}
 ---> Running in e483e65caf55
Removing intermediate container e483e65caf55
 ---> acf8ac829607
Step 8/9 : ADD ./db/database100.sql /docker-entrypoint-initdb.d
 ---> 42d992439f98
Step 9/9 : EXPOSE 3306
 ---> Running in 4e138502c6f9
Removing intermediate container 4e138502c6f9
 ---> a0818deda593
Successfully built a0818deda593
Successfully tagged db_image:latest
WARNING: Image for service db was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating reve_db_1 ... done

to see the containers:

docker ps -a

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
49419cb9980a        db_image            "docker-entrypoint.s…"   10 seconds ago      Up 8 seconds        0.0.0.0:3306->3306/tcp   reve_db_1

That is log for this container:

docker logs 49419cb9980a

2020-01-21T07:53:13.050129Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-01-21T07:53:13.051767Z 0 [Note] mysqld (mysqld 5.7.15) starting as process 1 ...
2020-01-21T07:53:13.054945Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-01-21T07:53:13.055053Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-01-21T07:53:13.055103Z 0 [Note] InnoDB: Uses event mutexes
2020-01-21T07:53:13.055179Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-01-21T07:53:13.055226Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2020-01-21T07:53:13.055268Z 0 [Note] InnoDB: Using Linux native AIO
2020-01-21T07:53:13.055608Z 0 [Note] InnoDB: Number of pools: 1
2020-01-21T07:53:13.055791Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-01-21T07:53:13.061164Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-01-21T07:53:13.072998Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-01-21T07:53:13.075325Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-01-21T07:53:13.101337Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-01-21T07:53:13.142134Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-01-21T07:53:13.142356Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-01-21T07:53:13.184613Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-01-21T07:53:13.185628Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-01-21T07:53:13.185733Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-01-21T07:53:13.186108Z 0 [Note] InnoDB: Waiting for purge to start
2020-01-21T07:53:13.236391Z 0 [Note] InnoDB: 5.7.15 started; log sequence number 12146163
2020-01-21T07:53:13.236828Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-01-21T07:53:13.237186Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-01-21T07:53:13.252074Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2020-01-21T07:53:13.252900Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2020-01-21T07:53:13.253023Z 0 [Note] IPv6 is available.
2020-01-21T07:53:13.253076Z 0 [Note]   - '::' resolves to '::';
2020-01-21T07:53:13.253184Z 0 [Note] Server socket created on IP: '::'.
2020-01-21T07:53:13.269950Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2020-01-21T07:53:13.270581Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2020-01-21T07:53:13.277379Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200121  7:53:13
2020-01-21T07:53:13.295467Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2020-01-21T07:53:13.367019Z 0 [Note] Event Scheduler: Loaded 0 events
2020-01-21T07:53:13.368851Z 0 [Note] mysqld: ready for connections.
Version: '5.7.15'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)

Now entered in the container:

docker exec -it 49419cb9980a bash

root@49419cb9980a:/#

I have checked if MYSQL_ROOT_PASSWORD is set correctly(in the container):

root@49419cb9980a:/# echo $MYSQL_ROOT_PASSWORD
123

Then tried to log into mysql:

root@49419cb9980a:/# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

My question is, how to solve this problem? Why can’t I access mysql? I tried with no password option too.
That gave me this error:

mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

This is my project structure:

tree
.
├── db
│   ├── Dockerfile
│   └── database100.sql
└── docker-compose.yml

1 directory, 3 files

1. Purpose

In this post, I would demo how to solve the following error when trying to access mysql in docker.

[email protected]:~/mysql# docker ps
CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                             PORTS                                       NAMES
fcbe5c899b25   mysql/mysql-server:latest   "/entrypoint.sh mysq…"   18 seconds ago   Up 14 seconds (health: starting)   127.0.0.1:3306->3306/tcp, 33060-33061/tcp   mysql
[email protected]:~/mysql# docker exec -it mysql bash
bash-4.4# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
bash-4.4# mysql -uroot -p -h127.0.0.1
Enter password:
ERROR 1130 (HY000): Host '127.0.0.1' is not allowed to connect to this MySQL server
bash-4.4# exit

2. What happened?

I am trying to deploy a mysql instance on my remote server, just as the following diagram shows:

image-20211030210011891

I started a docker on my server , the command is as follows:

docker run --name mysql 
    --restart=always 
    -v mysql-vol:/var/lib/mysql 
    -p 3306:3306 
    -e MYSQL_ROOT_PASSWORD=qweasd 
    -e MYSQL_DATABASE=testdb 
    -e MYSQL_USER=testuser 
    -e MYSQL_PASSWORD=123456 
    -d mysql/mysql-server:latest

I can explain the above options :

  • -v: –volume ,bind a volume, from host to container

    -v, --volume=[host-src:]container-dest[:<options>]: Bind mount a volume.
    The comma-delimited `options` are [rw|ro], [z|Z],
    [[r]shared|[r]slave|[r]private], and [nocopy].
    The 'host-src' is an absolute path or a name value.
      
    If neither 'rw' or 'ro' is specified then the volume is mounted in
    read-write mode.
      
    The `nocopy` mode is used to disable automatically copying the requested volume
    path in the container to the volume storage location.
    For named volumes, `copy` is the default mode. Copy modes are not supported
    for bind-mounted volumes.
      
    --volumes-from="": Mount all volumes from the given container(s)
    

  • -p means to bind a host port and map it to container port, from host to container.

    -P         : Publish all exposed ports to the host interfaces
    -p=[]      : Publish a container's port or a range of ports to the host
                   format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort
                   Both hostPort and containerPort can be specified as a
                   range of ports. When specifying ranges for both, the
                   number of container ports in the range must match the
                   number of host ports in the range, for example:
                       -p 1234-1236:1234-1236/tcp
      
                   When specifying a range for hostPort only, the
                   containerPort must not be a range.  In this case the
                   container port is published somewhere within the
                   specified hostPort range. (e.g., `-p 1234-1236:1234/tcp`)
      
                   (use 'docker port' to see the actual mapping)
    

  • -d means detach

To start a container in detached mode, you use -d=true or just -d option. 
By design, containers started in detached mode exit when the root process 
used to run the container exits, unless you also specify the --rm option. 
If you use -d with --rm, the container is removed when it exits or when 
the daemon exits, whichever happens first.

But when I go into the container and try to access mysql , I got this error:

[email protected]:~/mysql# docker ps
CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS                             PORTS                                       NAMES
fcbe5c899b25   mysql/mysql-server:latest   "/entrypoint.sh mysq…"   18 seconds ago   Up 14 seconds (health: starting)   127.0.0.1:3306->3306/tcp, 33060-33061/tcp   mysql
[email protected]:~/mysql# docker exec -it mysql bash
bash-4.4# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
bash-4.4# mysql -uroot -p -h127.0.0.1
Enter password:
ERROR 1130 (HY000): Host '127.0.0.1' is not allowed to connect to this MySQL server
bash-4.4# exit

3. How to solve it?

I tried to simplify the docker run command as follows:

docker run --name mysql 
    -p 3306:3306 
    -e MYSQL_ROOT_PASSWORD=qweabc 
    -e MYSQL_DATABASE=testdb 
    -e MYSQL_USER=testuser 
    -e MYSQL_PASSWORD=123456 
    -d mysql:5.7

I removed the -v and --restart options from the command line. Because there is no such directory mysql-vol in the directory where I run the command. And in the same time, I changed the docker image to mysql:5.7, which is a stable version.

Now test again, I got this:

[email protected]:~/mysql# docker ps
CONTAINER ID   IMAGE       COMMAND                  CREATED         STATUS         PORTS                               NAMES
75855f9cdbb4   mysql:5.7   "docker-entrypoint.s…"   5 seconds ago   Up 3 seconds   0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
[email protected]:~/mysql# docker exec -it 75 bash
[email protected]:/#
[email protected]:/#
[email protected]:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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>
mysql>

You can see that I succeeded to log on mysql in docker.

4. The reason

I think the key reason for the error are as follows:

  • The ‘-v’ option bind a local directory to docker volume, but it does not exist in local path.
  • The docker image file for mysql is very important, we should choose a version that is stable.

5. Summary

In this post, I demonstrated how to solve the ‘Access denied for user ‘root’@’localhost’’ or ‘Host ‘127.0.0.1’ is not allowed to connect to this MySQL server’ when using docker to install mysql. The key point is to find the right options to start your mysql container.


1

1

Пытаюсь получить доступ к MySql установленном внутри Docker контейнера
Выдается ошибка Access denied for user ‘root’@’172.18.0.5’ (using password: YES)
Здесь мой docker-compose.yml file:

version: '2'
services:
  #  The Application
  app:
    image: app
    working_dir: /var/www
    volumes:
      - /var/www/storage
    env_file: '.env'
    environment:
      - "DB_HOST=database"
      - "REDIS_HOST=cache"

  # The Web Server
  web:
    image: web
    ports:
      - "8000:80"

  # The Database
  database:
    image: mysql:5.7.19
    volumes:
      - dbdata:/var/lib/mysql
    environment:
      - MYSQL_DATABASE="dev"
      - MYSQL_USER="root"
      - MYSQL_PASSWORD="root"
      - MYSQL_ROOT_PASSWORD="root"
    ports:
      - "3306:3306"


  # redis
  cache:
    image: redis:3.0-alpine

volumes:
  dbdata:

собираю и запускаю все командами:

 
docker build -t app -f app.dockerfile .
build -t web -f web.dockerfile .
docker-compose -f docker-compose.yml up -d 

Пытаюсь подключиться с внешнего хоста и изнутри контейнера

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                           NAMES
819c5b90e1e1        mysql:5.7.19        "docker-entrypoint..."   20 seconds ago      Up 19 seconds       0.0.0.0:3306->3306/tcp          webapp_database_1
331c9b71701b        app       "docker-php-entryp..."   21 seconds ago      Up 21 seconds       9000/tcp                        webapp_app_1
a634f718dfc6        web       "nginx -g 'daemon ..."   12 days ago         Up 21 hours         443/tcp, 0.0.0.0:8000->80/tcp   webapp_web_1
6fa2801c08fd        redis:3.0-alpine    "docker-entrypoint..."   2 weeks ago         Up 21 hours         6379/tcp                        webapp_cache_1

$ docker port webapp_database_1 3306/tcp
0.0.0.0:3306

Докер запущен На виртуальном хосте

$ docker-machine ip
192.168.99.100

mysql -h 192.168.99.100 -P 3306 -u root -p
Enter password: ****
ERROR 1045 (28000): Access denied for user 'root'@'192.168.99.1' (using password: YES)

Даже, если попытаться соединиться изнутри контейнера

$ docker exec -it 819c5b90e1e1 /bin/bash
root@819c5b90e1e1:/# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Может неправильно написан .env файл?

APP_NAME=WEBAPP
APP_ENV=192.168.99.100
APP_KEY=base64:eKcu6C/Xg6Kok+sd6zJMc17WRucHh8tE1BZYnjfcV+c=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=192.168.99.100

DB_CONNECTION=mysql
DB_HOST=192.168.99.100
DB_PORT=3306
DB_DATABASE=dev
DB_USERNAME=root
DB_PASSWORD=root

Проект, в котором находится файл написан на Laravel. ОС Windows 10

15 Feb 2020 in Posts

Error — ER_ACCESS_DENIED_ERROR: Access denied for user ‘admin’@’localhost’ (using password: YES)

  • The Problem
    • What Works
      • PHPMyAdmin
      • MySQL Workbench
      • Docker Exec
    • What Doesn’t Work
      • MySQL Command Line
      • Node.js Driver For MySQL
    • Attempts To Fix
      • docker-compose rm -v
      • Validating Docker Container
      • Changing Docker Port
      • Explicit Permissions
  • The Solution

The Problem

For my Horsin’ Around application I have a docker-compose to spin up docker containers for MySQL and PHPMyAdmin. The yaml configuration file can be found here. These containers start up and work fine with a simple docker-compose up command.

What Works

PHPMyAdmin

I can connect to PHPMyAdmin using the root user (Username: root, Password: root). I can see that the horsin-around database was created successfully. The user admin is created and given full permissions to the horsin-around database from any host (signified by %).

MySQL Workbench

I can connect to the horsin-around database with MySQL Workbench with this configuration

  • Host: localhost
  • Port: 3306
  • User: admin
  • Password: admin

Docker Exec

I am also able to connect to the docker image and login to mysql with this command

docker exec -it mysql mysql --user=admin --password=admin

Then I was able to run SELECT USER(),CURRENT_USER(); and SHOW GRANTS; and get the expected output

mysql> SELECT USER(),CURRENT_USER();
+-----------------+----------------+
| USER()          | CURRENT_USER() |
+-----------------+----------------+
| admin@localhost | admin@%        |
+-----------------+----------------+
1 row in set (0.00 sec)

mysql> SHOW GRANTS;
+----------------------------------------------------------+
| Grants for admin@%                                       |
+----------------------------------------------------------+
| GRANT USAGE ON *.* TO 'admin'@'%'                        |
| GRANT ALL PRIVILEGES ON `horsin-around`.* TO 'admin'@'%' |
+----------------------------------------------------------+
2 rows in set (0.00 sec)

What Doesn’t Work

There are a lot of things that do work which makes the things that don’t work that much more confusing.

MySQL Command Line

I am unable to connect to connect using command line, I have tried all sorts of variations

mysql --user=admin --password=admin
mysql --user=admin --password=admin --database=horsin-around
mysql --user=admin --password=admin --database=horsin-around --port=3306
mysql --host=127.0.0.1 --user=admin --password=admin --database=horsin-around --port=3306
mysql --host=localhost --user=admin --password=admin --database=horsin-around --port=3306

But to no avail, each results in ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: YES)

I also tried specifying the protocol (tcp and socket)

mysql --host=localhost --user=admin --password=admin --database=horsin-around --port=3306 --protocol=tcp
mysql --host=localhost --user=admin --password=admin --database=horsin-around --port=3306 --protocol=socket

The socket protocol gave me the same error as above, the tcp protocol gave me this error

ERROR 2026 (HY000): SSL connection error: error:00000001:lib(0):func(0):reason(1)

I also tried changing localhost to 127.0.0.1, when using protocol of socket it resulted in this error

ERROR 2047 (HY000): Wrong or unknown protocol

Changing the protocol to tcp resulted in the Error 1045 above.

Node.js Driver For MySQL

The main problem is that when the application tries to connect to MySQL, it gets the following error

Error - ER_ACCESS_DENIED_ERROR: Access denied for user 'admin'@'localhost' (using password: YES)

I used a console.log to print the TypeORM ConnectionOptions and got the configuration I would expect

{
  type: 'mysql',
  host: 'localhost',
  port: 3306,
  database: 'horsin-around',
  username: 'admin',
  password: 'admin',
  synchronize: true,
  logging: true,
  dropSchema: false,
  ...
}

These are the same configuration options that I used to connect with MySQL Workbench and using the MySQL command line client

mysql --host=localhost --user admin --password=admin --database=horsin-around --port=3306

Attempts To Fix

There was a lot of Googling, trying this and trying that, tweaking and testing. These are some of the thigns I tried (and remembered to document).

docker-compose rm -v

I have tried deleting the volume folder and removing the docker images as suggested in this mysql docker-library issue

Validating Docker Container

I used a docker ps to look at the processes to see the host IP and ports

CONTAINER ID        IMAGE                   COMMAND                  CREATED              STATUS              PORTS      
              NAMES
ded1b34bde46        phpmyadmin/phpmyadmin   "/docker-entrypoint.…"   About a minute ago   Up About a minute   0.0.0.0:808
0->80/tcp     phpmyadmin
046254e59a92        mysql:5.7.21            "docker-entrypoint.s…"   About a minute ago   Up About a minute   0.0.0.0:330
6->3306/tcp   mysql

I tried chaning the host to 0.0.0.0, but that did not change anything.

I then checked to make sure that the docker port was not being forwarded to another port

$ docker port mysql 3306
0.0.0.0:3306

Changing Docker Port

To try and eliminate the possibility that a local instance onf MySQL was conflicting on port 3306, I updated my MYSQL_PORT environment variable to 3307 in my .env file.

# Remove local docker volume
$ rm -rf db_data/

# Remove docker images
$ docker-compose rm -v
Are you sure? [yN] y
Removing phpmyadmin ... done
Removing mysql      ... done

# Check docker container processes
$ docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                    NAMES
be4246d0d654        phpmyadmin/phpmyadmin   "/docker-entrypoint.…"   6 minutes ago       Up 6 minutes        0.0.0.0:8080->80/tcp     phpmyadmin
5a38be2c5365        mysql:5.7.21            "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        0.0.0.0:3307->3306/tcp   mysql

# Check port mapping
$ docker port mysql 3306
0.0.0.0:3307

# Attempt connection
$ mysql --host=localhost --user=admin --password=admin --database=horsin-around --port=3307
ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: YES)

I was again able to successfully connect using MySQL Workbench using the new port.

Explicit Permissions

There were so many StockOverflow answers that resulted in wrong password or user didn’t have the correct privileges. Because of this, I went into PHPMyAdmin and explicitely created and entry for admin@localhost

Explicit Admin Privileges

But trying to connect led to the same old errors

# TypeORM Connection
Error - ER_ACCESS_DENIED_ERROR: Access denied for user 'admin'@'localhost' (using password: YES)

# Command line client
ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: YES)

The Solution

I am extremely disapointed to not know what exactly fixed it, I tried again and it just worked. If I had to guess it was the Changing Docker Port, I think what might have happened is that the .env hadn’t been pulled in when it was run. I unfortunately do not know. But hopefully this post gives some ideas for things to try and checks to make.

grep 'temporary password' /var/log/mysqld.log
Sort date (newest date)

You may see something like this;

[root@SERVER ~]# grep 'temporary password' /var/log/mysqld.log
2016-01-16T18:07:29.688164Z 1 [Note] A temporary password is generated for root@localhost: O,k5.marHfFu
2016-01-22T13:14:17.974391Z 1 [Note] A temporary password is generated for root@localhost: b5nvIu!jh6ql
2016-01-22T15:35:48.496812Z 1 [Note] A temporary password is generated for root@localhost: (B*=T!uWJ7ws
2016-01-22T15:52:21.088610Z 1 [Note] A temporary password is generated for root@localhost: %tJXK7sytMJV
2016-01-22T16:24:41.384205Z 1 [Note] A temporary password is generated for root@localhost: lslQDvgwr3/S
2016-01-22T22:11:24.772275Z 1 [Note] A temporary password is generated for root@localhost: S4u+J,Rce_0t
[root@SERVER ~]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password:

If you see it says

... Failed! Error: Your password does not satisfy the current policy requirements
That means your password needs to have a character such as ! . # - etc...
mix characters well, upper case, lower case, ! . , # etc...

New password: 

Re-enter new password: 
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done! 
[root@SERVER ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 11
Server version: 5.7.10 MySQL Community Server (GPL)

Watch the last 10 minutes of this video, it teaches you how you do it.

I am receiving the error of ‘ERROR 1045 (28000): Access denied for user ‘root’@»localhost’ (using password: YES). I have looked at the permissions on portainer and was not able to find a way to view permissions on it.

# WARNING: Replace the example passwords with secure secrets. 
# WARNING: 'my_secret_phpipam_pass' and 'my_secret_mysql_root_pass'  version: '3'  services:   phpipam-web: 
    image: phpipam/phpipam-www:latest
     ports:       - "81:80"
     environment:       - TZ=Europe/London
       - IPAM_DATABASE_HOST=phpipam-mariadb
       - IPAM_DATABASE_PASS=my_secret_phpipam_pass
       - IPAM_DATABASE_WEBHOST=%
     restart: unless-stopped
     volumes:       - phpipam-logo:/phpipam/css/images/logo
     depends_on:
       - phpipam-mariadb
    phpipam-cron:
     image: phpipam/phpipam-cron:latest 
    environment:
       - TZ=Europe/London
       - IPAM_DATABASE_HOST=phpipam-mariadb
       - IPAM_DATABASE_PASS=my_secret_phpipam_pass
       - SCAN_INTERVAL=1h   
  restart: unless-stopped
     depends_on:       - phpipam-mariadb   phpipam-mariadb: 
    image: mariadb:latest 
    environment:     
  - MYSQL_ROOT_PASSWORD=my_secret_mysql_root_pass 
    restart: unless-stopped
     volumes:      
 - phpipam-db-data:/var/lib/mysql 
 volumes:   phpipam-db-data:
   phpipam-logo:

Понравилась статья? Поделить с друзьями:
  • Error 1045 28000 access denied for user root localhost using password yes centos
  • Error 1045 28000 access denied for user root localhost using password yes bitrix
  • Error 1045 28000 access denied for user root localhost using password no freebsd
  • Error 1045 28000 access denied for user root localhost using password no debian
  • Error 1045 28000 access denied for user odbc localhost using password yes