Creating a database in MySQL and MariaDB is a common task for developers and administrators. These two database management systems are widely used, open-source, and offer powerful tools for creating, managing, and querying data. Assigning permissions to a database is essential for controlling user access and ensuring data security. In this guide, we will walk through the process of creating a database, adding a user, and assigning permissions on MySQL and MariaDB in a few simple steps.
To follow this guide, you'll need to have MySQL or MariaDB installed on your system. MySQL and MariaDB share similar syntax and functionality, so the steps outlined in this guide will work for both systems. You'll also need to have access to the command-line interface or a graphical user interface (GUI) tool for managing databases.
By the end of this guide, you'll have a new database, a user with the necessary permissions, and a better understanding of how to manage databases in MySQL and MariaDB. Here's a step-by-step guide to help you accomplish this:
mysql -u root -p
CREATE DATABASE your_database;
CREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON your_database.* TO 'your_username'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Now you have successfully created a database, added a user, and assigned permissions in MySQL or MariaDB. You can now use this new database and user to manage and query data securely.
Comment anonymously. Login not required.