DEV Community

pcreem
pcreem

Posted on

Create mysql user and database

$sudo mysql
mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
mysql> \q

//login as newuser
$mysql -u newuser -p
mysql> CREATE DATABASE databasename; 

//option create table
mysql> CREATE TABLE Persons (
    PersonID int,
    LastName varchar(255),
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255)
);

//insert multiple data
INSERT INTO table_name (column_list)
VALUES
    (value_list_1),
    (value_list_2),
    ...
    (value_list_n);

Enter fullscreen mode Exit fullscreen mode

Top comments (0)