Home Backend Development PHP Problem What to do if linux php has insufficient permission to connect to mysql

What to do if linux php has insufficient permission to connect to mysql

Oct 26, 2021 am 10:01 AM
linux mysql php

Linux PHP has insufficient permissions to connect to MySQL: 1. Grant query, insert and other permissions to ordinary data users by using the grant command; 2. Grant permissions to create tables and indexes to database developers through grant. .

What to do if linux php has insufficient permission to connect to mysql

##The operating environment of this article: linux5.9.8 system, PHP version 7.1, DELL G3 computer

What should I do if linux php has insufficient permission to connect to mysql?

Linux php has insufficient permissions to connect to mysql. Mysql fine-grained permissions division:

mysql can grant you a user such as select, insert, update, delete, etc. One or more of the permissions mainly use the grant command. The usage format is:

grant 权限 on 数据库对象 to 用户
Copy after login

1. Grant ordinary data users have the right to query, insert, update, and delete all table data in the database

grant select on testdb.* to common_user@’%’
grant insert on testdb.* to common_user@’%’
grant update on testdb.* to common_user@’%’
grant delete on testdb.* to common_user@’%’
Copy after login

Or, use a mysql command instead:

grant select, insert, update, delete on testdb.* to common_user@’%’
Copy after login

2. Grant database developer, create tables, indexes, views, stored procedures, and functions. . . Waiting for permissions

grant 创建、修改、删除 mysql 数据表结构权限。
grant create on testdb.* to developer@’192.168.0.%’;
grant alter on testdb.* to developer@’192.168.0.%’;
grant drop on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 外键权限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 临时表权限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 索引权限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 视图、查看视图源代码 权限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show view on testdb.* to developer@’192.168.0.%’;
grant 操作 mysql 存储过程、函数 权限。
grant create routine on testdb.* to developer@’192.168.0.%’; - now, can show procedure status
grant alter routine on testdb.* to developer@’192.168.0.%’; - now, you can drop a procedure
grant execute on testdb.* to developer@’192.168.0.%’;
Copy after login

3. Grant ordinary DBA permissions to manage a certain mysql database

grant all privileges on testdb to dba@’localhost’
Copy after login

Among them, the keyword "privileges" can be omitted.

4. Grant senior dba manages the permissions of all databases in mysql

grant all on *.* to dba@’localhost’
Copy after login

5. Mysql grant permissions can be used at multiple levels

1. Grant works on On the entire mysql server:

grant select on *.* to dba@localhost; - dba 可以查询 mysql 中所有数据库中的表。
grant all on *.* to dba@localhost; - dba 可以管理 mysql 中的所有数据库
Copy after login

2. Grant acts on a single database:

grant select on testdb.* to dba@localhost; - dba 可以查询 testdb 中的表。
Copy after login

3. Grant acts on a single data table:

grant select, insert, update, delete on testdb.orders to dba@localhost;
Copy after login

4. Grant acts on On the columns in the table:

grant select(id, se, rank) on testdb.apache_log to dba@localhost;
Copy after login

5. Grant works on stored procedures and functions:

grant execute on procedure testdb.pr_add to ’dba’@’localhost’
grant execute on function testdb.fn_add to ’dba’@’localhost’
Copy after login

6. View mysql user permissions

View the current user (own) permissions :

show grants;
Copy after login

View other mysql user permissions:

show grants for dba@localhost;
Copy after login

7. Revoke permissions that have been granted to mysql user permissions

revoke has similar syntax to grant, you only need to add the keyword Just replace "to" with "from":

grant all on *.* to dba@localhost;
revoke all on *.* from dba@localhost;
Copy after login

8. Notes on mysql grant and revoke user permissions

1. After grant, revoke user permissions, the user can only reconnect to the mysql database , the permission can take effect.

2. If you want authorized users to grant these permissions to other users, you need the option "grant option"

grant select on testdb.* to dba@localhost with grant option;
Copy after login

This feature is generally not used. In practice, database permissions are best managed uniformly by the DBA.

Note: After modifying the permissions, you must refresh the service or restart the service

Recommended study: "

PHP Video Tutorial"

The above is the detailed content of What to do if linux php has insufficient permission to connect to mysql. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Docker on Linux: Containerization for Linux Systems Docker on Linux: Containerization for Linux Systems Apr 22, 2025 am 12:03 AM

Docker is important on Linux because Linux is its native platform that provides rich tools and community support. 1. Install Docker: Use sudoapt-getupdate and sudoapt-getinstalldocker-cedocker-ce-clicotainerd.io. 2. Create and manage containers: Use dockerrun commands, such as dockerrun-d--namemynginx-p80:80nginx. 3. Write Dockerfile: Optimize the image size and use multi-stage construction. 4. Optimization and debugging: Use dockerlogs and dockerex

How to safely store JavaScript objects containing functions and regular expressions to a database and restore? How to safely store JavaScript objects containing functions and regular expressions to a database and restore? Apr 19, 2025 pm 11:09 PM

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

CentOS: Security, Stability, and Performance CentOS: Security, Stability, and Performance Apr 21, 2025 am 12:11 AM

CentOS is the first choice for server and enterprise environments for its superior security, stability and performance. 1) Security provides forced access control through SELinux to improve system security. 2) Stability is supported by the LTS version for up to 10 years to ensure the stability of the system. 3) Performance significantly improves system response speed and resource utilization by optimizing kernel and system configuration.

How does MySQL differ from Oracle? How does MySQL differ from Oracle? Apr 22, 2025 pm 05:57 PM

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

See all articles