Home > Database > Mysql Tutorial > body text

How to solve the 1045 error of mysql in linux

WBOY
Release: 2022-06-28 16:30:00
Original
5332 people have browsed it

Solution: 1. After logging in to the database, use the "select host, user from user;" statement to query users and permissions; 2. Use "grant select, update, insert, delete on mas.* to create a new user @localhost identified by "password";" statement adds a user with normal permissions and logs in to the mysql database again.

How to solve the 1045 error of mysql in linux

The operating environment of this tutorial: linux7.3 system, mysql8.0.22 version, Dell G3 computer.

How to solve the 1045 error of mysql in Linux

When I started to use Linux to connect to the mysql database, a 1045 error occurred. When this problem occurs, it should be that the user has been denied access by the database, and we should open up permissions for your database.

1. Query database user permissions

Log in to the database and enter the linux command

mysql -uroot -padmin
Copy after login

Log in to your database and enter the user name and password

Use the database to query permissions

mysql> use mysql;
Copy after login
mysql> select host,user from user;
Copy after login

How to solve the 1045 error of mysql in linux

You can query users and permissions

2. If you want to remote mysql server, you need to add normal permissions The user

mysql> grant select,update,insert,delete on mas.* to root@localhost identified by "admin";
Copy after login

grant select,update,insert,delete on mas.* to create a new user @localhost identified by "password";

The meaning of this command is : Create a new user root, and only allow this user to log in locally (localhost), the password is admin, and grant it the select, update, and insert permissions on all tables in the mas database. We have a mas library here, so mas.* represents all tables under the mas library. Now the root user can log in to mysql, but it can still only log in locally.

If you want the root user to log in to mysql remotely, you need the following command:

mysql> update user set host = '%' where user = 'root';
Copy after login

We can also directly give the user permissions

grant all on *. * to username@"%" identified by "password";

##flush privileges; refresh privileges

Recommended learning:

mysql video tutorial

The above is the detailed content of How to solve the 1045 error of mysql in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template