検索
ホームページデータベースmysql チュートリアルMySQL ユーザーのパーセント記号 % に localhost が含まれているかどうかを分析しますか?

localhost を含まない MySQL ユーザーの割合は何ですか?

1 はじめに

MySQL を操作していると、時々 ## しか含まれないことがわかりました。 # が作成されました % のアカウントは localhost 経由で接続できますが、接続できない場合があります。オンライン検索では満足のいく答えが見つかりません。手動で試してみます。

推奨される学習: 「

mysql ビデオ チュートリアル >>

2 2 つの接続方法

ここで説明されている 2 つの接続方法は、

mysql# を実行するときに参照します。 ## command,-h パラメータには localhost または IP が入力されます。2 つの接続方法の違いは次のとおりです -h パラメータは localhost

## です。

#-h

パラメータが

localhost の場合、実際には socket が接続に使用されます (デフォルトの接続方法)。例は次のとおりです。

[mysql@mysql-test-83 ~]$ /usr/local/mysql57/bin/mysql -utest_user -p -hlocalhost
Enter password: 
========= 省略 ===========

mysql> status
/usr/local/mysql57/bin/mysql  Ver 14.14 Distrib 5.7.21, for linux-glibc2.12 (x86_64) using  EditLine wrapper

Connection id:        9
Current database:    
Current user:        test_user@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        5.7.21-log MySQL Community Server (GPL)
Protocol version:    10
Connection:        Localhost via UNIX socket
現在のユーザー から、ユーザーは

xx@localhost、接続方法は Localhost via UNIX ソケット#であることがわかります。 ##-h でパラメータは IP

-h

パラメータが

IP

の場合、実際には TCP は例は次のとおりです<pre class="brush:php;toolbar:false">[mysql@mysql-test-83 ~]$ /usr/local/mysql57/bin/mysql -utest_user -p -h127.0.0.1 Enter password:  ========= 省略 =========== mysql&gt; status -------------- /usr/local/mysql57/bin/mysql  Ver 14.14 Distrib 5.7.21, for linux-glibc2.12 (x86_64) using  EditLine wrapper Connection id:        11 Current database:     Current user:        test_user@127.0.0.1 SSL:            Cipher in use is DHE-RSA-AES256-SHA Current pager:        stdout Using outfile:        '' Using delimiter:    ; Server version:        5.7.21-log MySQL Community Server (GPL) Protocol version:    10 Connection:        127.0.0.1 via TCP/IP Server characterset:    utf8</pre>From現在のユーザーユーザーが

xx@127.0.0.1

で、接続方法が # であることがわかります。 ##TCP/IP3 バージョン間の違い テスト方法は、接続できるかどうかを確認することです。テストプロセスを見たくない場合は、次の方法を使用できます。最後までスクロールして結論を​​確認してください

3.1 MySQL 8.0

ユーザーを作成します

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.11    |
+-----------+
1 row in set (0.00 sec)

mysql> create user test_user@'%' identified by 'test_user';
Query OK, 0 rows affected (0.07 sec)
ローカルホストを使用してログイン

[root@mysql-test-72 ~]# /usr/local/mysql80/bin/mysql -utest_user -p -hlocalhost
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.11 MySQL Community Server - GPL
========= 省略 ===========

mysql> status
--------------
/usr/local/mysql80/bin/mysql  Ver 8.0.11 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)

Connection id:        9
Current database:    
Current user:        test_user@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        8.0.11 MySQL Community Server - GPL
Protocol version:    10
Connection:        Localhost via UNIX socket
...

IP を使用してログイン

[root@mysql-test-72 ~]# /usr/local/mysql80/bin/mysql -utest_user -p -h127.0.0.1
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11 MySQL Community Server - GPL
========= 省略 ===========

mysql> status
--------------
/usr/local/mysql80/bin/mysql  Ver 8.0.11 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)

Connection id:        8
Current database:    
Current user:        test_user@127.0.0.1
SSL:            Cipher in use is DHE-RSA-AES128-GCM-SHA256
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        8.0.11 MySQL Community Server - GPL
Protocol version:    10
Connection:        127.0.0.1 via TCP/IP

結果には、

MySQL

8.0

バージョン、

localhost 3.2 MySQL を含む % が表示されます。 5.7Create % user

db83-3306>>create user test_user@'%' identified by 'test_user';
Query OK, 0 rows affected (0.00 sec)
Use localhost to log in

[mysql@mysql-test-83 ~]$ /usr/local/mysql57/bin/mysql -utest_user -p -hlocalhost
========= 省略 ===========

mysql> status
/usr/local/mysql57/bin/mysql  Ver 14.14 Distrib 5.7.21, for linux-glibc2.12 (x86_64) using  EditLine wrapper

Connection id:        9
Current database:    
Current user:        test_user@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        5.7.21-log MySQL Community Server (GPL)
Protocol version:    10
Connection:        Localhost via UNIX socket
....

Use IP to log in

[mysql@mysql-test-83 ~]$ /usr/local/mysql57/bin/mysql -utest_user -p -h127.0.0.1
Enter password: 
========= 省略 ===========

mysql> status
--------------
/usr/local/mysql57/bin/mysql  Ver 14.14 Distrib 5.7.21, for linux-glibc2.12 (x86_64) using  EditLine wrapper

Connection id:        11
Current database:    
Current user:        test_user@127.0.0.1
SSL:            Cipher in use is DHE-RSA-AES256-SHA
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        5.7.21-log MySQL Community Server (GPL)
Protocol version:    10
Connection:        127.0.0.1 via TCP/IP
Server characterset:    utf8
...

Result Display

5.7

バージョン

MySQL

% localhost3.3 MySQL 5.6 を含むユーザー

db83-3306>>select version();
+------------+
| version()  |
+------------+
| 5.6.10-log |
+------------+
1 row in set (0.00 sec)

db83-3306>>create user test_user@'%' identified by 'test_user';
Query OK, 0 rows affected (0.00 sec)
Use localhostログインするには

[mysql@mysql-test-83 ~]$ /usr/local/mysql57/bin/mysql -utest_user -p -hlocalhost
Enter password: 
ERROR 1045 (28000): Access denied for user 'test_user'@'localhost' (using password: YES)

IP を使用してログインしてください

[mysql@mysql-test-83 ~]$ /usr/local/mysql57/bin/mysql -utest_user -p -h127.0.0.1
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.10-log MySQL Community Server (GPL)
========= 省略 ===========

mysql> status
--------------
/usr/local/mysql57/bin/mysql  Ver 14.14 Distrib 5.7.21, for linux-glibc2.12 (x86_64) using  EditLine wrapper

Connection id:        3
Current database:    
Current user:        test_user@127.0.0.1
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        5.6.10-log MySQL Community Server (GPL)
Protocol version:    10
Connection:        127.0.0.1 via TCP/IP
......
--------------

結果は、

MySQL 5.6

%

localhost## が含まれていないことを示しています。 #3.4 MySQL 5.1ユーザーの作成<pre class="brush:php;toolbar:false">mysql&gt; select version(); +-----------+ | version() | +-----------+ | 5.1.73    | +-----------+ 1 row in set (0.00 sec) mysql&gt; create user test_user@'%' identified by 'test_user'; Query OK, 0 rows affected (0.00 sec)</pre>ローカルホストを使用してログイン

[root@chengqm ~]# mysql -utest_user -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'test_user'@'localhost' (using password: YES)

IPを使用してログイン

[root@chengqm ~]# mysql -utest_user -p -h127.0.0.1
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4901339
Server version: 5.1.73 Source distribution
========= 省略 ===========

mysql> status
--------------
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

Connection id:        4901339
Current database:    
Current user:        test_user@127.0.0.1
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        5.1.73 Source distribution
Protocol version:    10
Connection:        127.0.0.1 via TCP/IP

結果Display

5.1

%

のバージョンには

localhost

3.5 MariaDB 10.3Create user<pre class="brush:php;toolbar:false">db83-3306&gt;&gt;select version(); +---------------------+ | version()           | +---------------------+ | 10.3.11-MariaDB-log | +---------------------+ 1 row in set (0.000 sec) db83-3306&gt;&gt;create user test_user@'%' identified by 'test_user'; Query OK, 0 rows affected (0.001 sec)</pre>## が含まれていません#localhost を使用してログインします

[mysql@mysql-test-83 ~]$ /usr/local/mariadb/bin/mysql -utest_user -p -hlocalhost
Enter password: 
ERROR 1045 (28000): Access denied for user 'test_user'@'localhost' (using password: YES)
IP を使用してログインします

[mysql@mysql-test-83 ~]$ /usr/local/mariadb/bin/mysql -utest_user -p -h127.0.0.1
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.3.11-MariaDB-log MariaDB Server
========= 省略 ===========

MariaDB [(none)]> status
--------------
/usr/local/mariadb/bin/mysql  Ver 15.1 Distrib 10.3.11-MariaDB, for Linux (x86_64) using readline 5.1

Connection id:        12
Current database:    
Current user:        test_user@127.0.0.1
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server:            MariaDB
Server version:        10.3.11-MariaDB-log MariaDB Server
Protocol version:    10
Connection:        127.0.0.1 via TCP/IP

結果は、

MariaDB 10.3

%

localhost

を除くと表示されます。

4 結論 バージョン

ユーザーの

% に localhost が含まれるかどうかMySQL5.7MySQL5.6含まれていません
##MySQL8.0includes
includes
MySQL5.1 含まれない
MariaDB 10.3 含まれない

以上がMySQL ユーザーのパーセント記号 % に localhost が含まれているかどうかを分析しますか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明
この記事はsegmentfaultで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。
新しいMySQLユーザーに権限を付与する方法新しいMySQLユーザーに権限を付与する方法May 09, 2025 am 12:16 AM

tograntpermissionstonewmysqlusers、フォローステープ:1)Accessmysqlasauserwithsufthiveerprivileges、2)createanewuser withthecreateusercommand、3)usethegrantcommandtospecifypermissionsionsionsionsionsionsionsionsionsionsionselect、挿入、挿入、挿入、更新、4)

MySQLにユーザーを追加する方法:ステップバイステップガイドMySQLにユーザーを追加する方法:ステップバイステップガイドMay 09, 2025 am 12:14 AM

toadduusersinmysqucrectivally andcurally、soflowthesteps:1)usethecreateuserstatementtoaddanewuser、指定するhostandastrongpassword.2)補助金を使用して、補助金を使用して、補助すること、

MySQL:複雑な権限を持つ新しいユーザーの追加MySQL:複雑な権限を持つ新しいユーザーの追加May 09, 2025 am 12:09 AM

toaddanewuserwithpermissionsinmysql、followthesesteps:1)createtheuserwithcreateuser'newuser '@' localhost'identifiedifiedifiedifiedby'pa ssword ';。2)grantreadacestoalltablesin'mydatabase'withgrantselectonmydatabase.to'newuser'@'localhost';。3)grantwriteaccessto '

MySQL:文字列データ型とコレクションMySQL:文字列データ型とコレクションMay 09, 2025 am 12:08 AM

MySQLの文字列データ型には、CHAR、VARCHAR、バイナリ、Varbinary、BLOB、およびテキストが含まれます。照合は、文字列の比較とソートを決定します。 1.Charは固定長の文字列に適しており、Varcharは可変長文字列に適しています。 2.バイナリとVarbinaryはバイナリデータに使用され、BLOBとテキストは大規模なオブジェクトデータに使用されます。 3. UTF8MB4_UNICODE_CIなどのルールのソートは、高度と小文字を無視し、ユーザー名に適しています。 UTF8MB4_BINは症例に敏感であり、正確な比較が必要なフィールドに適しています。

MySQL:Varcharsにはどの長さを使用すればよいですか?MySQL:Varcharsにはどの長さを使用すればよいですか?May 09, 2025 am 12:06 AM

最適なMySQLVarcharの列の長さの選択は、データ分析に基づいており、将来の成長を検討し、パフォーマンスの影響を評価し、文字セットの要件を評価する必要があります。 1)データを分析して、典型的な長さを決定します。 2)将来の拡張スペースを予約します。 3)パフォーマンスに対する大きな長さの影響に注意してください。 4)ストレージに対する文字セットの影響を考慮します。これらの手順を通じて、データベースの効率とスケーラビリティを最適化できます。

mysql blob:制限はありますか?mysql blob:制限はありますか?May 08, 2025 am 12:22 AM

mysqlblobshavelimits:tinyblob(255bytes)、blob(65,535bytes)、mediumblob(16,777,215bytes)、andlongblob(4,294,967,295bytes).tousebl難易度:1)PROFFORMANCESANDSTORERGEBLOBSEXTERNALLY;

MySQL:ユーザーの作成を自動化するための最良のツールは何ですか?MySQL:ユーザーの作成を自動化するための最良のツールは何ですか?May 08, 2025 am 12:22 AM

MySQLでユーザーの作成を自動化するための最良のツールとテクノロジーには、次のものがあります。1。MySQLWorkBench、中小サイズの環境に適した、使いやすいがリソース消費量が高い。 2。アンシブル、マルチサーバー環境に適した、シンプルだが急な学習曲線。 3.カスタムPythonスクリプト、柔軟性がありますが、スクリプトセキュリティを確保する必要があります。 4。大規模な環境に適した人形とシェフ、複雑ですがスケーラブル。選択する際には、スケール、学習曲線、統合のニーズを考慮する必要があります。

mysql:blob内で検索できますか?mysql:blob内で検索できますか?May 08, 2025 am 12:20 AM

はい、youcansearchinsideablobinmysqlusingspecifictechniques.1)converttheblobtoautf-8stringwithconvert function andsearchusinglike.2)

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

mPDF

mPDF

mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。

VSCode Windows 64 ビットのダウンロード

VSCode Windows 64 ビットのダウンロード

Microsoft によって発売された無料で強力な IDE エディター

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境