are you sure your code is inserting the data in right tables?
Main Topics
Browse All TopicsCan you create a user and grant privileges using CREATE USER and GRANT in a stored procedure using variables from a web page? I have code in my stored procedure to insert into the USER and DB tables but when I try to connect from my web page I receive an access denied error. However, when I create a new user via the MYSQL Admin gui I have no problem connecting from my web page. MYSQL 5, PHP 5, APACHE 2, Windows xp. My store procedure code:
CREATE DEFINER=`root`@`localhost`
BEGIN
DECLARE temp_password varchar(45);
set temp_password = concat('test',right(rand()
start transaction;
/*insert mymathhelper.clients (name,password,chg_passwor
VALUES(parm_name,
temp_password,
1);*/
insert mysql.user
( Host,
User,
Password,
Select_priv,
Execute_priv,
ssl_cipher,
x509_issuer,
x509_subject )
values
('localhost',
parm_name,
temp_password,
'Y',
'Y',
'null',
'null',
'null'
);
insert mysql.db
( Host,
Db,
User,
Select_priv,
Execute_priv)
values
('localhost',
'mymathhelper',
parm_name,
'Y',
'Y');
commit;
END
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I think, it should be:
CREATE DEFINER=`root`@`localhost`
BEGIN
DECLARE temp_password varchar(45);
set temp_password = concat('test',right(rand()
start transaction;
/*insert mymathhelper.clients (name,password,chg_passwor
VALUES(parm_name,
temp_password,
1);*/
insert INTO mysql.user
( Host,
User,
Password,
Select_priv,
Execute_priv,
ssl_cipher,
x509_issuer,
x509_subject )
values
('localhost',
parm_name,
temp_password,
'Y',
'Y',
'null',
'null',
'null'
);
insert INTO mysql.db
( Host,
Db,
User,
Select_priv,
Execute_priv)
values
('localhost',
'mymathhelper',
parm_name,
'Y',
'Y');
commit;
END
The procedure is call using by a guest account that has execute privileges. The connection is made using the parms ("localhost", "guest", "guest password", "database name"). The user and grants table rows are being created. I'm concerned that since I'm manually inserting these tables that I'm missing some info that is created by using "create user". I'm testing all of this from a single laptop. PHP connects via Apache as localhost.
Business Accounts
Answer for Membership
by: mankowitzPosted on 2007-08-06 at 19:35:50ID: 19643042
does your website access mysql with the same credentials as the local machine? When you log on as admin, you may be using the superuser account, while the web user has a more limited account.