http://blog.chinaacc.com/garfiled606/blog/20100119-1909060539272.html Client connections:
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
Attention:
(1) Server port flag-P must be larger to distinguish the user-p, if the direct connection database flag-D also uppercase;
(2) If you want to enter the password directly after-P can not leave a space such as-pmypassword;
(3) there is no '; ' semicolon at the end of the command.
Example:
mysql-u lzpddd-pmypassword-h 192.168.1.88-p 3306-d mydb
Change Password
Format: Mysqladmin-u username-P Old password password new password
1, Example 1: Add a password to root ab12. First enter directory Mysqlbin under DOS, and then type the following command
Mysqladmin-uroot-password AB12
Note: Because Root does not have a password at the beginning, the-p old password can be omitted.
2, Example 2: Then change the root password to djg345.
MYSQLADMIN-UROOT-PAB12 Password djg345
Add new users (note: Unlike the above, the following are commands in the MySQL environment, so there is a semicolon followed by a command terminator)
Format: Grant Select on database. * To User name @ login host identified by \ "Password \"
Example 1, add a user test1 password for ABC, so that he can log on any host, and all databases have query, insert, modify, delete permissions. First, use the root user to connect to MySQL, and then type the following command:
Grant Select,insert,update,delete on * * to [email protected]\ "%\" identified by \ "Abc\";
But example 1 increases the user is very dangerous, you want to like someone to know test1 password, then he can be on any computer on the Internet to log on your MySQL database and to your data can do whatever, workaround see Example 2.
Example 2, add a user test2 password for ABC, so that he can only login on localhost, and the database mydb can be queried, inserted, modified, deleted * (localhost refers to the local host, that is, the MySQL database host), This allows the user to use a password that knows test2, and he cannot access the database directly from the Internet, but only through a Web page on the MySQL host.
Grant Select,insert,update,delete on mydb.* to [e-mail protected] identified by \ "Abc\";
If you do not want to test2 have a password, you can call another command to erase the password.
Grant Select,insert,update,delete on mydb.* to [email protected] identified by \ "\";
Common Commands
Select database (); #显示已选择的数据库SELECT last_insert_id (); #显示最后一条数据插入的IDset character_set_results= ' GBK '; #改变控制台编码格式, For example: Change the console code to gbkalter table Your_table auto_increment; #mysql设置表列自增列值
MySQL Common commands