Connecting to the MySQL Server
客戶端程式連線MySql服務
1. 不指定連線引數
因為沒有指定引數,將使用預設值語法:shell> mysql
預設主機名為:localhost
[root@root ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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>
2. 指定主機名和使用者名稱和密碼
語法:shell> mysql --host=localhost --user=myname --password=mypass mydb
shell> mysql -h localhost -u myname -pmypass mydb
host:主機名 user:登入的使用者 password:密碼 mydb:訪問的資料庫
[root@qingmeng001 ~]# mysql --host=localhost --user=chenwx --password=chenwx mysql
Warning: Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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>
[root@qingmeng001 ~]# mysql -h localhost -u chenwx -pchenwx mysql
Warning: Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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>
note:使用-p或 --password指定密碼,在-p或-password後不能有空格
3.避免因安全問題,指定-p或-password選項不直接跟密碼
語法:shell> mysql --host=localhost --user=myname --password mydb
shell> mysql -h localhost -u myname -p mydb
[root@qingmeng001 ~]# mysql --host=localhost --user=chenwx --password mysql
Enter password: --輸入密碼,不顯示輸入內容及輸入個數
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 5.6.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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>
4.指定IP和協議
語法:shell> mysql --host=127.0.0.1
shell> mysql --protocol=TCP
--protocol={TCP|SOCKET|PIPE|MEMORY}
在一些unix系統中需要強制指定TCP/IP,否則指定的埠號將唄忽略
5. 配置ipv6
--host=::1.6. 使用TCP/IP連線到遠端伺服器
語法:shell> mysql --host=remote.example.com
預設埠:3306
7.指定埠選項--port -P
語法:shell> mysql --host=remote.example.com --port=13306
8. windows使用named-pipe連線
語法:
--pipe
--protocol=PIPE
--protocol
Value Connection Protocol Permissible Operating Systems
TCP TCP/IPconnection to local or remote server All
SOCKET Unix socket file connection to local server Unix only
PIPE Named-pipe connection to local or remote serverWindows only
MEMORY Shared-memory connection to local serverWindows only
--pipe
--protocol=PIPE
--protocol
Value Connection Protocol Permissible Operating Systems
TCP TCP/IPconnection to local or remote server All
SOCKET Unix socket file connection to local server Unix only
PIPE Named-pipe connection to local or remote serverWindows only
MEMORY Shared-memory connection to local serverWindows only
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28282660/viewspace-1579988/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Troubleshooting: Connecting to SQL Server When System Administrators Are Locked OutSQLServer
- 機器學習之nltk download出錯:Error connecting to server: [Errno -2]機器學習ErrorServer
- Connecting to Nomounted databaseDatabase
- Connecting Oracle with MS-AccessOracle
- MySQL Server Startup ScriptMySqlServer
- MySQL server5.7版出現server failedMySqlServerAI
- Connecting with Administrative Privileges: Example (33)
- 【MySQL】檢視MySQL Server引數方法MySqlServer
- MySQL server has gone awayMySqlServerGo
- MySQL client server 協議MySqlclientServer協議
- Mysql修改server uuidMySqlServerUI
- MySQL Server架構概述MySqlServer架構
- MySQL:Lost connection to MySQL server at 'readingMySqlServer
- mysql關於mysql.server的總結MySqlServer
- MySQL master and slave have equal MySQL server UUIDsMySqlASTServerUI
- GoldenGate&ASM&Connecting to a 'BLOCKED' instanceGoASMBloC
- MYSQL The Server Shutdown Process(筆記)MySqlServer筆記
- MySQL Server-id的作用MySqlServer
- [轉]Connecting OBIEE 11.1.1.7 to Hadoop Data SourcesHadoop
- Connecting to ASM through the TNS Listener from a Client DesktopASMclient
- SQL Server建立dblink至MySQLServerMySql
- Host 'localhost' is not allowed to connect to this MySQL serverlocalhostMySqlServer
- NavicatPremium 連線SQL Server 、MySQL等REMServerMySql
- MySql與Sql Server Update語句MySqlServer
- Mysql與Sql Server DATEDIFF函式MySqlServer函式
- 問題MySQL server has gone awayMySqlServerGo
- mysql server 5.5 version版本初識MySqlServer
- CentOS7安裝MySQL ServerCentOSMySqlServer
- MySQL server PID file could not be found!MySqlServer
- mysql cluster 一臺server安裝MySqlServer
- 【Mysql】character-set-server引數MySqlServer
- MS SQL Server和MySQL區別ServerMySql
- MySQL5.7 Unable to find a match: MySQL-community-serverMySqlUnityServer
- mysql遠端連線 Host * is not allowed to connect to this MySQL serverMySqlServer
- MySQL-1130-host ... is not allowed to connect to this MySql serverMySqlServer
- How can I prevent users from connecting to a USB storage device?dev
- 上手MySQL之解決問題:not allowed to connect to this MySQL serverMySqlServer
- MysqL錯誤之_ERROR! MySQL server PID file could not be found!MySqlErrorServer