为什么我不能使用--login-path = local登录mysql?

时间:2016-02-23 18:35:42

标签: mysql

我刚刚将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选项登录的内容?

2 个答案:

答案 0 :(得分:0)

您应该使用套接字在本地登录。尝试使用mysql_config_editor选项来指定--socket=/path/to/mysqld.sock命令,该命令对您的MySQL实例是正确的。

答案 1 :(得分:0)

为您的密码添加双引号。它对我有用。