1, connect to Mysql
Format: mysql -h host address -u username -p user password
Connect to MYSQL on this machine.
First open the DOS window, and then enter the directory mysql bin, and then type the command mysql -u root -p, after the carriage return prompts you to enter the password. Note that the user name can have spaces or no spaces, but the password must be no space, otherwise let You re-enter your password.
If you just installed MYSQL, the superuser root has no password, so you can enter MYSQL directly by pressing Enter. The MYSQL prompt is: mysql>2, connect to MYSQL on the remote host.Assume that the remote host's IP address is 188.8.131.52, the user name is root, and the password is abcd123.Then type the following command: mysql -h184.108.40.206 -u root -p 123; (Note: u and root can be without spaces, the other is the same) 3, exit MYSQL command: exit (Enter)
2, change the password
Format: mysqladmin -u username -p old password password new password
1. Add a password ab12 to the root.
First, enter the directory mysqlbin under DOS, and then type the following command: mysqladmin -u root -password ab12 Note: Since the root has no password at the beginning, the -p old password can be omitted.
2, then change the root password to djg345.
Mysqladmin -u root -p ab12 password djg345
3, add new users
Note: Unlike the above, the following is a command in the MYSQL environment, so it is followed by a semicolon as the command terminator format: grant select on database.* to user name @ login host identified by "password"
1, increase a user test1 password abc, so that he can log on any host, and all databases have query, insert, modify, delete permissions.First connect to MYSQL as the root user and type the following command:
Grant select, insert, update, delete on *.* to [email=test1@”%]test1@”%[/email]” Identified by “abc”; but added users are very dangerous and you want to be someone Know the password of test1, then he can log on to your mysql database on any computer on the internet and your data can do whatever you want. For solution, see 2.
2, increase a user test2 password abc, so that he can only log in on the localhost, and can query, insert, modify, delete operations on the database mydb (localhost refers to the local host, the host where the MYSQL database is located),
In this way, the user uses the password of test2 and he cannot access the database directly from the internet. It can only be accessed through the web page on the MYSQL host.
Grant select, insert, update, delete on mydb.* to [email=test2@localhost]test2@localhost[/email] identified by “abc”; if you do not want test2 to have a password, you can use a command to remove the password.
Grant select, insert, update, delete on mydb.* to [email=test2@localhost]test2@localhost[/email] identified by "";