I'm trying find a way to create mysql users with passwords using php code, i.e. without using phpmyadmin, mysql wizard or any else.
Is there a way to do this?
I'm trying find a way to create mysql users with passwords using php code, i.e. without using phpmyadmin, mysql wizard or any else.
Is there a way to do this?
you can do this with MySQL Queries:
CREATE USER 'new_username'@'localhost' IDENTIFIED BY 'password_for_new_username';
See also http://crunchbang.org/archives/2008/04/17/create-mysql-user-accounts-from-the-command-line/
Hope that helps you.
You can send any of the account management commands to the database just like any other query. Of course, it may not be good from a security perspective if your website user account has the privileges in the database to do these things. (Accounts used for public application purposes should generally be kept to minimum necessary privileges.) But that's another matter entirely.
The SQL code for this would be:
CREATE DATABASE db_name;
USE db_name;
CREATE TABLE users(id int not null auto_increment, username varchar(20), password varchar(50));
But I really don't know why would you like to do this trough PHP though. Can you please explain why you need this code for?
Also it will definitely help if you have at least basic knowledge of SQL syntax (tutorials should t be hard to find with a simple search...).