command line how to connect to a database remotely

Source: Internet
Author: User
Tags server port

1, login server side, enter the command line, Windows cmd; 2, set the user, password to allow the specified IP access:MySQL-U root-p or installed shortcuts enter:MySQLCommand Line Client,using the GRANT command: Grant permissions 1, Permissions 2,... Permission n on the database name. Table name to User name @ user address identified by ' connection password '; Example:MySQL>grant Select,insert,update,delete,create,drop on mydb.mytable to [e-mail protected] identified by ' MyPassword '; give from 192The. 168.1.88 user LZPDDD assigns permissions to operations such as Select,insert,update,delete,create,drop on the MyTable table of the database mydb, and sets the password to ' MyPassword ';MySQL>grant all privileges on * * to [e-mail protected] identified by ' MyPassword '; give from 192The. 168.1.88 user LZPDDD assigns permission limits for all operations on all tables in all databases and sets the password to ' MyPassword ';MySQL>grant all privileges on * * to [e-mail protected] '% ' identified by ' MyPassword ', assigning a user lzpddd from any IP address a permission limit for all operations on all tables in all databases, and setting the password to' MyPassword ';3, shutting down the server-side firewall or opening port 3306 (very important);4, Client connection: Go to command line, Windows cmd, connect:MySQL-u user name-p password-H server IP address-P server-side MySQL port number-D Database name Note: (1) Server port flag-P must be larger to distinguish it from user-p, if direct connection to database flag-d also be capitalized; (2) If you want to enter the password directly after-P can not leave a space such as-Pmypassword; (3) The end of the command does not have '; 'semicolon. Example:MySQL-U lzpddd-pmypassword-h 192.168.1.88-p 3306-D mydbMySQL-U root-p123456-h 192.168.1.64-p 3306-D mydb Note: Ubuntu needs to modify the file$sudogedit/etc/MySQL/my.CNF Skip-networking =#skip-networkingor Bind-address=127.0.0.1 = bind-address=your machine's IP local MySQL connection linux environment MySQL (remote connection) INSERT intoMySQL. User (Host,user,password) VALUES ('% ', ' root ', Password (' 123456 '))); FLUSHprivileges; GRANT all Privileges on*. * to "root" @ '% ' identified by ' 123456 'With GRANT OPTION;MySQL-U root-p123456-h 192.168.1.64-p 3306MySQL-5.6.23-linux-glibc2.5-x86_64.tar.GZ./bin/mysqladmin-u root password ' new-password './bin/mysqladmin-u root-h papaserver2 password ' new-password '

command line how to connect to a database remotely

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.