MySQL在命名过程中所遇到的常见问题总结
本文通过问答的开式来解答在mysql在命名用过程中所遇到的常见问题。
谁能连接,从那儿连接?
你可以允许一个用户从特定的或一系列主机连接。有一个极端,如果你知道降职从一个主机连接,你可以将权限局限于单个主机:
GRANT ALL ON samp_db.* TO boris@localhost IDENTIFIED BY "ruby"GRANT ALL ON samp_db.* TO fred@res.mars.com IDENTIFIED BY "quartz"
(samp_db.*意思是“samp_db数据库的所有表)另一个极端是,你可能有一个经常旅行并需要能从世界各地的主机连接的用户max。在这种情况下,你可以允许他无论从哪里连接:
GRANT ALL ON samp_db.* TO max@% IDENTIFIED BY "diamond"
“%”字符起通配符作用,与LIKE模式匹配的含义相同。在上述语句中,它意味着“任何主机”。所以max和max@%等价。这是建立用户最简单的方法,但也是最不安全的。
取其中,你可以允许一个用户从一个受限的主机集合访问。例如,要允许mary从snake.net域的任何主机连接,用一个%.snake.net主机指定符:
GRANT ALL ON samp_db.* TO mary@.snake.net IDENTIFIED BY "quartz";
如果你喜欢,用户标识符的主机部分可以用IP地址而不是一个主机名来给定。你可以指定一个IP地址或一个包含模式字符的地址,而且,从MySQL 3.23,你还可以指定具有指出用于网络号的位数的网络掩码的IP号:
GRANT ALL ON samp_db.* TO boris@192.168.128.3 IDENTIFIED BY "ruby" GRANT ALL ON samp_db.* TO fred@192.168.128.% IDENTIFIED BY "quartz" GRANT ALL ON samp_db.* TO rex@192.168.128.0/17 IDENTIFIED BY "ruby"
第一个例子指出用户能从其连接的特定主机,第二个指定对于C类子网192.168.128的IP模式,而第三条语句中,192.168.128.0/17指定一个17位网络号并匹配具有192.168.128头17位的IP地址。
如果MySQL抱怨你指定的用户值,你可能需要使用引号(只将用户名和主机名部分分开加引号)。
GRANT ALL ON samp_db.president TO "my friend"@"boa.snake.net"
用户应该有什么级别的权限和它们应该适用于什么?
你可以授权不同级别的权限,全局权限是最强大的,因为它们适用于任何数据库。要使ethel成为可做任何事情的超级用户,包括能授权给其它用户,发出下列语句:
GRANT ALL ON *.* TO ethel@localhost IDENTIFIED BY "coffee" WITH GRANT OPTION
ON子句中的*.*意味着“所有数据库、所有表”。从安全考虑,我们指定ethel只能从本地连接。限制一个超级用户可以连接的主机通常是明智的,因为它限制了试图破解口令的主机。
有些权限(FILE、PROCESS、RELOAD和SHUTDOWN)是管理权限并且只能用"ON *.*"全局权限指定符授权。如果你愿意,你可以授权这些权限,而不授权数据库权限。例如,下列语句设置一个flush用户,他只能发出flush语句。这可能在你需要执行诸如清空日志等的管理脚本中会有用:
GRANT RELOAD ON *.* TO flushl@localhost IDENTIFIED BY "flushpass"。
一般地,你想授权管理权限,吝啬点,因为拥有它们的用户可以影响你的服务器的操作。
数据库级权限适用于一个特定数据库中的所有表,它们可通过使用ON db_name.*子句授予:
GRANT ALL ON samp_db TO bill@racer.snake.net INDETIFIED BY "rock" GRANT SELECT ON samp_db TO ro_user@% INDETIFIED BY "rock"
第一条语句向bill授权sambitsCN.com
以上就是MySQL在命名过程中所遇到的常见问题总结的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

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.
