Welcome to the Linux community forum and interact with 2 million technical staff to access 6 rowsinset (0.01sec). The first method is grant. You can assign permissions to users. all indicates all permissions, can be changed to select, insert, update, delete, followed *. * indicates that all databases have permissions. The general format is database name.
Welcome to the Linux community forum and interact with 2 million technical staff> go to 6 rows in set (0.01 sec). The first method is grant. You can assign permissions to users, all indicates all permissions, which can be changed to select, insert, update, delete, followed *. * indicates that all databases have permissions. The general format is database name.
Welcome to the Linux community forum and interact with 2 million technicians>
6 rows in set (0.01 sec)
The first method is grant. You can specify permissions for users. all indicates all permissions. You can change them to select, insert, update, delete, and *. * indicates that all databases have permissions. The general format is database name. * "Test" indicates the user name, "123" indicates the password, and "localhost" indicates the matched host. You can also change it to another one, such as "". If it is null, it indicates all hosts. The second method is to directly modify the database table, but you do not have the specified permissions. To ensure security, you should grant the corresponding permissions to the user. Viewing user information is also an SQL statement. Of course, you can also use select * from mysql. user; To view more information, the password here is encrypted. Delete a user, that is, an SQL statement: delete from mysql. user where user = 'xxx ';.
Of course, this still doesn't work. After operating the user table, you have to add the command flush privileges; refresh the system permission table; otherwise, even if the added user is not available, the deleted user can log on.
3. mysql access problems
The most common problem with accessing mysql is that the password is empty. At the beginning, I did not change the root password for convenience, however, the subsequent operations are always problematic, Which is inexplicable. Therefore, we recommend that you change the password to a non-empty one after installing mysql.
Problem 1. Access denied for user 'root' @ 'localhost' (using password: NO)
Access denied for user 'root' @ 'localhost' (using password: YES)
If I didn't change the root password, I asked him to leave it blank and then log on through mysql-u root. After several logins, the using password: NO error was inexplicably reported, well, I will log on through mysql-u root-p, and press enter without prompting me to enter the password. Mom still reports the error of using password: NO. So I should try the password mysqladmin-u root-p password '000000'. The error mysqladmin: connect to server at 'localhost' failed and using password: YES is reported.
So I started it in mysqld_safe mode and checked the mysql. user data. The root password in it is indeed empty. Can I have fun together.
After searching on the Internet, many people have encountered the same problem as me. The solution is to modify the user table and change the root password to a non-empty one:
#/Etc/init. d/mysql stop
# Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &
# Mysql-u root mysql
Mysql> UPDATE user SET Password = PASSWORD ('000000') where USER = 'root ';
Mysql> flush privileges;
Mysql> quit
#/Etc/init. d/mysqld restart
# Mysql-uroot-p
Enter password: <输入新设的密码123>
Problem 2. ERROR 1044 (42000): Access denied for user ''@ 'localhost' to database' db _ mysql'
By chance, I logged in with an empty root password and created a database db_mysql. the following error was reported: How did I log on as a root user, this is a user. I didn't create this user at all, and then select * from mysql. user; check, there is such a user, the user name and password are empty, but my root login is actually such an empty user, the reason is not clear yet, but it may be related to the root password being empty, so I searched for a solution and deleted the empty user:
# Service mysqld stop
# Mysqld_safe -- skip-grant-table
Open a new terminal to execute
# Mysql-u root mysql
Mysql> delete from user where USER = '';
Mysql> flush privileges;
Mysql> \ q
These problems are related to the empty password. When I change the root password to a non-empty password, I have not encountered these problems when I log on again, therefore, we recommend that you change the root password after installing mysql. Of course, the using password: YES error may also occur when the password is incorrect during logon. This is irrelevant to the empty password.
[1] [2]