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.
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';
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With