Methods to limit the maximum number of connections per user for a MySQL database

Source: Internet
Author: User

There are always some Web site users on the server is too large, and affect the normal use of other sites, then how to put a certain smelly fish in their own acres of three points? Methods to limit the maximum number of connections for a single user in a MySQL database I'll take a look at the methods and principles below:


1, for Linux and Uinx operating system need to find MY.CNF, for Windows operating system need to find My.ini


2, because my file is a MySQL configuration file, we previously only know that he is the overall control of the MySQL database, in fact, he can also restrict the individual users.


3, the my.cnf or My.ini download down, edit, you can remove the superfluous items, add:


Max_connections = 10//Indicates that the user is limited to the maximum number of connections 10, but do not upload the wrong place Oh! Methods to limit the maximum number of connections per user for a MySQL database


Of course, for other projects can also be added below, such as the number of concurrent, buffering, etc., Play it yourself!


4. Upload your modified file to the user's MySQL directory, for example, you built a database called ABC, you put him under ABC.


So the operation can make smelly fish rotten in their own pot, haha haha ha! How to limit the maximum number of connections for a single user in a MySQL database it's genius.


However, there is an easier way to enter a command:


Mysql-u root-p


Input: GRANT all on customer.* to ' database name ' @ ' localhost '

Input: Identified by ' database name '

Input: With max_user_connections 4 (limit maximum number of connections)

Input: Max_connections_per_hour 1000; (Limit the maximum number of connections per hour)


You can also enter directly: GRANT all on customer.* to ' database name ' @ ' localhost ' with max_user_connections 4 Max_connections_per_hour 1000;


Then restart MySQL!

GRANT all on Dcrosdata (database name). * to ' dcrosdata_f (user name) ' @ '% ' with max_user_connections Max_connections_per_hour 1000;


Methods to limit the maximum number of connections per user for a MySQL database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.