1. Maintenance of the root user password: After MySQL is installed, MySQL automatically provides a root user without a password. To ensure security, set the password for the root user: # mysqladmin-u root password 123 (123 is the password, which can also be written as '123456' or "123"); you cannot directly enter mysql when logging in after setting the password, some parameters must be followed: [root @ localhost ~] # Mysql-u root-p (-u followed by the login username,-p prompted to log on with a password) Enter password :( Enter the password) Change password: [root @ localhost ~] # Mysqladmin-u root-p password 123456 (password is followed by the new password to be updated) Enter password :( Enter the original password and press Enter) 2. add and delete other users: log on as a root user. There is a mysql in mysql. the user table stores the information tables of all users in MySQL. Therefore, you can add or delete users by adding or deleting records of the table. 1. add A user (in two forms):. mysql> grant all on *. * to yushan @ "%" identified by "123"; mysql> flush privileges; (refresh the system permission table) (the execution will be completed in mysql. insert a record to the user table. "all" indicates all permissions (including add, delete, modify, and query permissions) of "-www.2cto.com ),*. * Indicates all databases, yushan indicates the username added, 123 indicates the password, and % indicates all matched hosts. Can be specified, such as grant select, update on db. * to yushan @ localhost identified by '100 ";) B. directly to mysql. user adds a record mysql> insert into mysql. user (Host, User, Password) values ("localhost", "yusuhan", password ("123"); mysql> flush privileges: the yushan password is 123 (the password is encrypted), but you do not have the permission because only three fields are added. You can also add the permission through grant: mysql> grant all on *. * to yushan @ localhost identified by '123 "; mysql> flush privileges; (refresh the system permission table) It's a bit cool. If you want to remotely log on to MySQL, you must keep up with the Host Ip address as follows: [root @ localhost ~] # Mysql-u yushan-p-h 192.168.59.123 Enter password :( Enter the password) 2. delete user: mysql> delete from mysql. user where user = 'yushan '; mysql> flush privileges; (refresh the system permission table) other users' passwords are modified the same as those of root users, in this case, flush privileges must be set up after the add or delete operations. In this way, the deleted user can log on to the deleted user, especially after the user is deleted, all of the above operations are performed under the MySQL root User. To ensure MySQL security, you should specify the corresponding permissions for the user.
Author: sky CppBlog.com