0

Is there a command link wizard to create a new MySQL username and a DB with the same name + password?

As for now, I always do so online from PHPmyadmin, but would like to automize this process from CLI.

The way I need should create a username + DB with the same name, in the same command.

  • Why don't you just use the mysql cli? – Charles Addis Jul 18 '17 at 6:43
0

Sort of. What you can do is create a text file with all the details in it. For example, lets call it auto.sql:

create database <name of db>;
grant all privileges on <name of db>.* 
    to '<user name>'@'localhost' identified by '<password>'
    with grant option;
use <name of db>;
create table `<table name>` 
    (<... column details ..>, <... index details, etc ...>);
create table `<another table>` 
    (<... column details ..>, <... index details, etc ...>);

Then, as the root user you can import auto.sql:

mysql -u root -p < auto.sql

This should create the DB, the user and create the tables for the DB as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.