MySQL uses stored procedures to create users

Source: Internet
Author: User
Tags mysql version

Friday received a small help to develop a friend, need in The MySQL test environment creates a stored procedure that automatically creates a user and asks for help writing.
MySQL version 5.5.17
OS version CentOS 6.4
The contents of the stored procedure are as follows:

DELIMITER//create PROCEDURE cr_user (in P_uname varchar (a), in p_passwd Varachar (+)) begindecalre p_sqlt varchar (1000) ; SET p_sqlt = concat (' Create user ', P_uname, ' identified by \ ', p_passwd, ' \ '); SET @cr_sentence = p_sqlt; PREPARE EC1 from @cr_sentence; EXECUTE EC1; End//delimiter;

A user who has execute and has the Create user right calls this function to create the appropriate user.

This article is from the "DBA Sky" blog, so be sure to keep this source http://kevinora.blog.51cto.com/9406404/1897025

MySQL uses stored procedures to create users

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.