You can connect to mysql remote database from the command line provided you have mysql client installed in your local system, you have the credentials for your mysql remote database connection and finally remote connection is allowed for your mysql remote database.
Install mysql client in your local system –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
## ---------------- ## RHEL | CentOS OS ## ---------------- ## Install mysql client sudo yum install mysql ## ------------------ ## Ubuntu | Debian OS ## ------------------ ## Install mysql client sudo apt-get install mysql ## --------- ## Fedora OS ## --------- ## Install mysql client sudo dnf -y install mysql ## ---------- ## Windows OS ## ---------- ## Check if Chocolety is already installed choco --version #should return an output ## Install Chocolety if not already installed ## Open a command propmt as admin and execute below command @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" ## Install mysql client using chocolety choco install mysql ## ------ ## MAC OS ## ------ ## Check if Homebrew already installed brew --version #should return an output ## Install Homebrew if not already installed /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ## Install mysql client using homebrew brew install mysql |
Connect to a remote mysql database from your local system –
1 2 3 4 5 |
## Connect to mysql database ## Replace \ with ` for Powershell and ^ for command prompt mysql -u -h -D |