Assuming you already have MySQL installed, here are the commands to create a new MySQL database:
First, we log in into MySQL using the root credentials you specified during installation of MySQL:
sudo mysql -u root -p
When prompted, enter your password for mysql-user root
.
Next, let’s create a new database:
CREATE DATABASE exampleDB;
Now, we have to create a new user who is going to be allowed to connect to this new database ExampleDB
. Bear in mind, that this user does not need to exist on your system. The following user and password is mainly used via your scripts to connect to the database:
GRANT ALL ON exampleDB.* TO 'new_user' IDENTIFIED BY 'some_strong_password';
In the last step we are flushing the privileges to reload the GRANT tables and exit the MySQL shell:
FLUSH PRIVILEGES; quit
0 Comments