IT

오류 1044 (42000) : ''@ 'localhost'사용자가 데이터베이스 'db'에 대한 액세스가 거부되었습니다.

lottoking 2020. 6. 10. 07:56
반응형

오류 1044 (42000) : ''@ 'localhost'사용자가 데이터베이스 'db'에 대한 액세스가 거부되었습니다.


MySQL에서 쿼리 작성을 시작하고 싶습니다.

show grants 보여줍니다 :

+--------------------------------------+
| Grants for @localhost                |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+

나는 사용자 ID가 없지만 사용자를 만들고 싶을 때 특권이 없으며 한 명의 사용자가 없어도 권한을 만드는 방법을 모릅니다!

mysql> CREATE USER 'parsa'@'localhost' IDENTIFIED BY 'parsa';
ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER pr
ivilege(s) for this operation

루트로 로그인하려고했습니다.

mysql> 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 'mysql
 -u root -p' at line 1
mysql> mysql -u root -p root;
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 'mysql
 -u root -p root' at line 1

아니요, mysql -u root -pMySQL 명령 줄이 아닌 bash에서 실행해야합니다 . mysql에 있다면 exit를 입력하여 종료 할 수 있습니다 .


MySQL 데이터베이스에 대한 루트 계정을 설정해야 할 수도 있습니다.

터미널 유형에서 :

mysqladmin -u root password 'root password goes here'

그런 다음 MySQL 클라이언트를 호출하십시오.

mysql -h localhost -u root -p

나는 다른 문제로 여기로 데려왔다. 로그인하려고 할 때마다 올바르게 인증하는 대신 익명 사용자로 로그인했기 때문에 해당 메시지가 나타납니다. 내 문제에 대한 해결책은 다음과 같습니다.

현재 사용자 및 사용 권한을 확인하려면 다음을 수행하십시오.

select user(), current_user();

성가신 익명 사용자를 삭제하려면

drop user ''@'localhost';

이것은 사용자 권한과 관련이 있습니다. 적절한 보조금을 제공하면이 문제가 해결됩니다.

단계 [1] : 터미널을 열고이 명령을 실행하십시오

$ mysql -uroot -p

출력 [1] : 아래와 같이 mysql 프롬프트가 나타납니다.

여기에 이미지 설명을 입력하십시오

2 단계]:

mysql> CREATE USER 'parsa'@'localhost' IDENTIFIED BY 'your_password';
mysql> grant all privileges on *.* to 'parsa'@'localhost';

통사론:

mysql> grant all privileges on `database_name`.`table_name` to 'user_name'@'hostname';

노트 :

  • 호스트 이름은 IP 주소, 로컬 호스트, 127.0.0.1 일 수 있습니다.
  • 에서 database_name/ table_name* 수단 모든 데이터베이스
  • 에서 hostname모든 호스트를 지정하려면 '%'를 사용하십시오.

단계 [3] : quit/ exit명령을 입력하거나을 눌러 현재 mysql 프롬프트에서 빠져 나오십시오 Ctrl+D.

단계 [4] : 새로운 사용자로 로그인

$ mysql -uparsa -pyour_password

단계 [5] : 데이터베이스 생성

mysql> create database `database_name`;

전체 로그인 명령을 시도 할 수 있습니다.

mysql -h host -u root -p 

어디 호스트가 될 것입니다 127.0.0.1.

협력이 존재하는지 확인하기 위해이 작업을 수행하십시오.

Using mysql -u root -p allows me to do a a lot of database searching, but refuses any database creation due to a path setting.


First, if you are unfamiliar with the command line, try using phpmyadmin from your webbrowser. This will make sure you actually have a mysql database created and a username.

This is how you connect from the command line (bash):

mysql -h hostname -u username -p database_name

For example:

fabio@crunchbang ~ $ mysql -h 127.0.0.1 -u fabio -p fabiodb

If you are in mysql shell, exit it by typing exit. It will return you to the command prompt. Now start mysql by using exactly the following command:

sudo mysql -u root -p

If your username is something other than root, replace 'root' in the above command with your username:

sudo mysql -u your-user-name -p

It will then ask you the mysql-account-password, and your mysql won't show any access privilege issue from now.


@Nickparsa … you have 2 issues:

1). mysql -uroot -p should be typed in bash (also known as your terminal) not in MySQL command-line. You fix this error by typing

exit

in your MySQL command-line. Now you are back in your bash/terminal command-line.

2). You have a syntax error:

mysql -uroot -p; 

the semicolon in front of -p needs to go. The correct syntax is:

mysql -uroot -p

type the correct syntax in your bash commandline. Enter a password if you have one set up; else just hit the enter button. You should get a response that is similar to this: 여기에 이미지 설명을 입력하십시오

Hope this helps!


Most Developers log-in to server(I assume you r having user-name and password for mysql database) then from Bash they switch to mysql> prompt then use the command below(which doesn’t work

mysql -h localhost -u root -p

해야 할 일은 bash 프롬프트에서 위의 명령을 사용하는 것입니다-> 그렇게하면 암호가 주어지면 mysql 프롬프트로 직접 가져갑니다.

그런 다음 데이터베이스, 테이블을 하나씩 만들 수 있습니다

비슷한 교착 상태에 직면하여 경험을 공유했습니다.


위의 답변에 따라 올바른 명령을 받았는데, 내가 놓친 것은 Workbench에서 사용자에 대한 '호스트에서 연결 제한'을 언급하고 기본값은 "%"입니다.이 값을 "localhost"로 변경하면 그 후에 잘 연결됩니다!

참고 URL : https://stackoverflow.com/questions/8838777/error-1044-42000-access-denied-for-user-localhost-to-database-db

반응형