Access mysql remote database from command line

后端 未结 17 1504
忘掉有多难
忘掉有多难 2020-11-28 01:41

I have a server with Rackspace. I want to access the database from my local machine command line.

I tried like:

mysql -u username -h my.application.com         


        
相关标签:
17条回答
  • 2020-11-28 02:03

    For Mac, use the following command:

    mysql -u app -h hostaddress -P port -D dbname -p
    

    and then enter the password when prompted.

    0 讨论(0)
  • 2020-11-28 02:04

    mysql servers are usually configured to listen only to localhost (127.0.0.1), where they are used by web applications.

    If that is your case but you have SSH access to your server, you can create an ssh tunnel and connect through that.

    On your local machine, create the tunnel.

    ssh -L 3307:127.0.0.1:3306 -N $user@$remote_host
    

    (this example uses local port 3307, in case you also have mysql running on your local machine and using the standard port 3306)

    Now you should be ale to connect with

    mysql -u $user -p -h 127.0.0.1 -P 3307
    
    0 讨论(0)
  • 2020-11-28 02:05

    If you are on windows, try Visual Studio Code with MySQL plugins, an easy and integrated way to access MySQL data on a windows machine. And the database tables listed and can execute any custom queries.

    0 讨论(0)
  • 2020-11-28 02:06

    simply put this on terminal at ubuntu:

    mysql -u username -h host -p
    

    Now hit enter

    terminal will ask you password, enter the password and you are into database server

    0 讨论(0)
  • 2020-11-28 02:06

    I assume you have MySQL installed on your machine. Execute the command below after filling missing details:

    mysql -uUSERNAME -pPASSWORD -hHOSTNAME -P3306 
    
    0 讨论(0)
  • 2020-11-28 02:07

    This one worked for me in mysql 8, replace hostname with your hostname and port_number with your port_number, you can also change your mysql_user if he is not root

          mysql --host=host_name --port=port_number -u root -p
    

    Further Information Here

    0 讨论(0)
提交回复
热议问题