TECHNIG
Gateway for IT Experts and Tech Geeks

How to Create MySQL Database on Linux VPS or Dedicated Server?

I’m installing a PHP web application on a Linux cloud VPS. It needs MySQL database and Username granted access to the database. So in this short step by step guide, you will learn how to create MySQL database on a Linux VPS or any dedicated server.

The process is easy, just need to know some SQL server query structure. This article works on Linux and Windows. The MySQL server command line structure is the same on Linux operating systems and Windows systems.

How to Create MySQL Database?

Before you going to create MySQL database, you must log in to your VPS server via SSH, Telnet or even connect to VPS via remote desktop graphically.

When you connected to your VPS Server or dedicated server, type the following command to create a database inside MySQL Server.

1. Connect to VPS using PuTTY with SSH and connect to MySQL Server with the command “mysql -p” command then enter the password.

Connect to MySQL Server in Linux VPS to Create MySQL Database - Technig
Connect to MySQL Server in Linux VPS  to Create MySQL Database – Technig

2. Check the currently available databases in MySQL server with “show databases;” command.

List MySQL Databases with Show Database Command
List MySQL Databases with Show Database Command

Note: The information_schema, MySQL, performance_schema and PHPMyAdmin databases are the built-in.

3. Now type “create database TechnigDB;” then press enter to create the database named “TechnigDB“. See the result with previous show databases command.

How to Create Database in MySQL Server - Technig
How to Create Database in MySQL Server – Technig

Note: Type you own database name instead of “TechnigDB“. Also, name the databases related to your projects name.

The database in MySQL server created successfully. Now you need to setup a user for connecting to this database with full permission. When you install some PHP script or web applications, you must have a database and username.

How to Create User in MySQL server?

Like creating a database in MySQL, a user is also created with “create” command line. Try the following command to create a user name and give full access to the database.

1. Create database with “create user ‘Shams’@’localhost’ identified by ‘UserPassWordHere’;“. This command will create a user named “Shams” with password “UserPassWordHere”.

How to Create User in MySQL server
How to Create User in MySQL server

2. Set the “Shams” user to “TechnigDB” database which created previously with “grant all privileges on TechnigDB.* to ‘Shams’@’localhost’;” command.

Add User to MySQL Database with full Privileges
Add User to MySQL Database with full Privileges

3. Finally, once reload the MySQL users privileges to refresh the permissions with “flush privileges;” command.

Reload Privileges with Flush command
Reload Privileges with Flush command

Greate job, you did all successfully. Anyway if you have any issue related to MySQL server configuration, ask us through the comment section. We will resolve your issue quickly.


Searches related to how to create database in MySQL

MySQL create database and user
how to create database in MySQL workbench
how to create database in SQL
how to create table in MySQL
MySQL create database utf8
how to create database in PHPMyAdmin
What is a schema in MySQL?
How do I open a SQL database?
How can I connect MySQL database?

Leave A Reply

Your email address will not be published.