我刚刚将 MySQL 数据库从 5.5 更新到 5.6。我正在尝试 follow best practices所以我使用 mysql_config_editor
创建了一个 .mylogin.cnf
文件:
mysql_config_editor set --login-path=local --host=localhost --user=example --password
但是,当我尝试 mysql --login-path=local
时出现此错误:
ERROR 1045 (28000): Access denied for user 'example'@'localhost' (using password: YES)
但是,我仍然可以使用 mysql -u example -p
登录,然后在提示符处粘贴密码。我已经三重检查了我在 mysql_config_editor
命令中使用的密码是否正确。
我的资助看起来像这样:
mysql> show grants;
+------------------------------------------------------------------------------+
| Grants for example@localhost |
+------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'example'@'localhost' IDENTIFIED BY PASSWORD <secret> |
| GRANT ALL PRIVILEGES ON `example`.* TO 'example'@'localhost' |
+------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
这是当我重新启动 MySQL 时 /var/log/mysql/error.log
的输出:
160223 12:31:41 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
160223 12:31:42 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2016-02-23 12:31:43 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-23 12:31:43 0 [Note] /usr/sbin/mysqld (mysqld 5.6.29) starting as process 31337 ...
2016-02-23 12:31:43 31337 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2016-02-23 12:31:43 31337 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2016-02-23 12:31:43 31337 [Warning] Using unique option prefix myisam_recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2016-02-23 12:31:43 31337 [Note] Plugin 'FEDERATED' is disabled.
2016-02-23 12:31:43 31337 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-02-23 12:31:43 31337 [Note] InnoDB: The InnoDB memory heap is disabled
2016-02-23 12:31:43 31337 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-02-23 12:31:43 31337 [Note] InnoDB: Memory barrier is not used
2016-02-23 12:31:43 31337 [Note] InnoDB: Compressed tables use zlib 1.2.8
2016-02-23 12:31:43 31337 [Note] InnoDB: Using Linux native AIO
2016-02-23 12:31:43 31337 [Note] InnoDB: Using CPU crc32 instructions
2016-02-23 12:31:43 31337 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-02-23 12:31:43 31337 [Note] InnoDB: Completed initialization of buffer pool
2016-02-23 12:31:43 31337 [Note] InnoDB: Highest supported file format is Barracuda.
2016-02-23 12:31:43 31337 [Note] InnoDB: 128 rollback segment(s) are active.
2016-02-23 12:31:43 31337 [Note] InnoDB: Waiting for purge to start
2016-02-23 12:31:43 31337 [Note] InnoDB: 5.6.29 started; log sequence number 1660606
SSL error: Unable to get certificate from '/etc/mysql/server-cert.pem'
2016-02-23 12:31:43 31337 [Warning] Failed to setup SSL
2016-02-23 12:31:43 31337 [Warning] SSL error: Unable to get certificate
2016-02-23 12:31:43 31337 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2016-02-23 12:31:43 31337 [Note] - '127.0.0.1' resolves to '127.0.0.1';
2016-02-23 12:31:43 31337 [Note] Server socket created on IP: '127.0.0.1'.
2016-02-23 12:31:43 31337 [Note] Event Scheduler: Loaded 0 events
2016-02-23 12:31:43 31337 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.29' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
您是否在日志中看到任何可能表明我无法使用 --login-path
选项登录的原因?
最佳答案
为您的密码添加双引号。它对我有用。
关于mysql - 为什么我不能使用--login-path=local 登录mysql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35585473/