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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL:Lost connection to MySQL server at 'readingMySqlServer
- MySQL Server Startup ScriptMySqlServer
- Mysql修改server uuidMySqlServerUI
- MySQL 2003 - Can’t connect to MySQL server on (10060)MySqlServer
- MySQL-1130-host ... is not allowed to connect to this MySql serverMySqlServer
- MySQL Server架構概述MySqlServer架構
- MySQL client server 協議MySqlclientServer協議
- MySQL server has gone awayMySqlServerGo
- mysql關於mysql.server的總結MySqlServer
- MYSQL The Server Shutdown Process(筆記)MySqlServer筆記
- “Host ‘xxxx‘ is not allowed to connect to this MySQL server“MySqlServer
- SQL Server建立dblink至MySQLServerMySql
- Host 'localhost' is not allowed to connect to this MySQL serverlocalhostMySqlServer
- ssh-add 報錯:Error connecting to agent No such file or directoryError
- MySQL5.7 Unable to find a match: MySQL-community-serverMySqlUnityServer
- mysql,mariaDB,Percona Server,MongoDB,Redis,RocksDBMySqlServerMongoDBRedis
- Windows Server 2012配置MySQL 8.0.20 MGRWindowsServerMySql
- Lost connection to MySQL server at 'reading authorization packet'MySqlServer
- Host 'xxx' is not allowed to connect to this MySQL server.MySqlServer
- 問題MySQL server has gone awayMySqlServerGo
- NavicatPremium 連線SQL Server 、MySQL等REMServerMySql
- 上手MySQL之解決問題:not allowed to connect to this MySQL serverMySqlServer
- Mysql mysql lost connection to server during query 問題解決方法MySqlServer
- Mac安裝壓縮版MySQL ServerMacMySqlServer
- ERROR 1290 (HY000): The MySQL server is running withErrorMySqlServer
- 同一Linux下起兩臺Mysql ServerLinuxMySqlServer
- mysql 啟動報錯Can't connect to local MySQL server through socket '/data/mysql/mysql/mysql.sock'(111)MySqlServer
- Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock錯誤MySqlServer
- Navicat連線centos裡mysql報錯Host is not allowed to connect to this MySQL serverCentOSMySqlServer
- mysql 5.7.21 CMake Error: The source directory "/data/server/mysql" does not appear to contain CMakMySqlErrorServerAPPAI
- Oracle 12C ORA-12545 While Connecting to RAC through SCAN NameOracleWhile
- sql server匯入mysql,使用工具SQLyogServerMySql
- Laradock 部署 Laravel+MySQL+Redis+Laravel-echo-serverLaravelMySqlRedisServer
- Host 'xxx' is not allowed to connect to this MySQL server 解決方法MySqlServer
- MySql/Oracle和SQL Server的分頁查MySqlOracleServer
- MySQL8.0.11 Community Server 與 驅動 mysql-connector-java-8.0.11.jarMySqlUnityServerJavaJAR
- MySQL報錯ERROR 2013 (HY000): Lost connection to MySQL server during queryMySqlErrorServer
- 解決MySql報錯:1130 - Host ‘xxx‘ is not allowed to connect to this MySQL server的方法MySqlServer
- Thinkphp mysql 資料庫斷線重連 MySQL server has gone awayPHPMySql資料庫ServerGo