Since the installation of MySQL in Redhat Enterprise 5, this time to practice the management of MySQL users;
First, the root user password maintenance:
Since MySQL is installed, MySQL will automatically provide a root user without a password, and set the password to root for security purposes:
#mysqladmin-U root password 123 (123 is a password, can also be written as: ' 123 ' or ' 123 ');
You can not enter MySQL directly after setting the password, you must follow some parameters, as follows:
[Root@localhost ~]# mysql-u root-p (-u followed by login username,-p prompts for password login)
Enter Password: (enter password)
Modify Password:
[root@localhost ~] #mysqladmin-u root-p password 123456 (password followed by the new password to be updated)
Enter Password: (input original password, enter can)
Ii. additions and deletions of other users:
Log in as root, there is a mysql.user table in MySQL is the information table that stores all the users in MySQL, so you can add and remove users by directly adding records to delete this table.
1. Add users (in two forms):
A.mysql> Grant all on *.* to yushan@ "%" identified by "123";
Mysql>flush privileges; (Refresh system Permission table)
(After the execution will insert a record in the Mysql.user table, all to indicate all permissions (including additions and deletions), *.* means all databases, Yushan for the added username, 123 for the password,% for all matching hosts, the above information can be specified as Grant SELECT, Update on db.* to yushan@localhost identified by ' 123 ';)
B. Add a record directly to Mysql.user
mysql> INSERT INTO Mysql.user (Host,user,password) VALUES ("localhost", "Yusuhan", Password ("123"));
Mysql>flush privileges;
This creates a user named: Yushan password: 123 (password is encrypted), but does not have permissions because only three fields are added, you can add permissions through grant:
Mysql>grant all on *.* to yushan@localhost identified by ' 123 ';
Mysql>flush privileges; (Refresh system Permission table)
(This seems a bit verbose.) Directly with Grant soon)
Add user if you want to log in MySQL remotely, you must keep up with the host IP as follows:
[Root@localhost ~]# mysql-u yushan-p-H 192.168.59.123
Enter Password: (enter password)