Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a database for an existing user in MySQL? [closed]

Tags:

mysql

I want to create a database for a particular (existing) user in MySQL. How do I do that ?

What i tried -

CREATE USER 'myuser' @'%' IDENTIFIED BY 'mypass';
CREATE DATABASE myuser.myDatabase;

The second line is wrong. I cannot find the proper syntax.

Please tell me my mistake.

like image 557
stella matthew Avatar asked Aug 16 '12 00:08

stella matthew


People also ask

How do I grant a database to MySQL user?

To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name. * TO 'username'@'localhost';

How do I manually create a database in MySQL?

Open the MySQL Workbench as an administrator (Right-click, Run as Admin). Click on File>Create Schema to create the database schema. Enter a name for the schema and click Apply. In the Apply SQL Script to Database window, click Apply to run the SQL command that creates the schema.


1 Answers

when i create a user named test and create a db named test in phpmyadmin it runs:

CREATE USER 'test'@'localhost' IDENTIFIED BY  '***';

GRANT USAGE ON * . * TO  'test'@'localhost' IDENTIFIED BY  '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

CREATE DATABASE IF NOT EXISTS  `test` ;

GRANT ALL PRIVILEGES ON  `test` . * TO  'test'@'localhost';

this may help you.

like image 103
alpera Avatar answered Nov 14 '22 22:11

alpera