首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MYSQL在使用正确的语法并以受限匿名用户身份登录时出错

问MYSQL在使用正确的语法并以受限匿名用户身份登录时出错
EN

Stack Overflow用户
提问于 2013-07-31 12:43:43
回答 1查看 131关注 0票数 0

我已经搜索了整个互联网,并询问了工作中的几个人如何解决这个问题,但我准备放弃……我在笔记本电脑上安装了mySQL,但无法以用户身份登录。

代码语言:javascript
复制
Raymunds-MacBook-Pro:~ raymundsinlao$ /usr/local/mysql/bin/mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2149
Server version: 5.6.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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> -u root -p;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-u root -p' at line 1
mysql> 

当我尝试登录时,它告诉我语法错误。我尝试了很多不同的方法,但都不起作用。

我的另一个问题是我是一个匿名用户,所以除了information_schema和test之外,我不能访问任何数据库。

代码语言:javascript
复制
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.00 sec)
mysql> use mysql;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
mysql>

在过去的两天里,我尝试了几十种不同的方法,并在8+上花了几个小时。请帮帮我!

EN

回答 1

Stack Overflow用户

发布于 2013-07-31 12:48:34

您正在分隔/usr/local/mysql/bin/mysql和-u root -p,但这两者都属于命令行,因此它应该如下所示:

代码语言:javascript
复制
/usr/local/mysql/bin/mysql -u root -p

事实上,您只能使用/usr/local/mysql/bin/mysql登录,这意味着您已经以root身份登录,只是该用户没有密码,而且您肯定希望为该帐户设置密码(一旦登录):

代码语言:javascript
复制
use mysql;
update user set password=PASSWORD('NEWPASSWORD') where User='root';
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17961778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档