개발 창고/Database
[MariaDB] How to create database and account
로이제로
2024. 4. 4. 23:36
반응형
TOC is not supported in this version (ex.Mobile)
The first thing you do after you build a database is create a database where that data is stored and create an account to access that database. I'll write about the establishment of the MariaDB database later.
First, access mariadb with root privileges. (Mariadb is based on mysql, so mysql has many similarities in commands.)
1. Connect to MariaDB
$> sudo mysql -u root
2. Create Database
create database {mydatabase};
3. Create Account
create user '{userName}’@'localhost' identified by '{userPassword}';
- For localhost, you can use % or a fixed IP instead of localhost when you access it from the outside only.
- Depending on the versionup, some MariaDBs are generally inaccessible because the password is encrypted if you use the above command. In this case, you must create and access it as follows.
4. Grant created DATABASE privileges to the USER
grant all privileges on {mydatabase}.* to ‘{userName}’@'localhost';
- For localhost, you can use % or a fixed IP instead of localhost if you are using it internally only.
5. Apply Setting
flush privileges;
In this article, {} is a random change, so you can change it to the name you want if necessary.
ex) When creating a database called product
create database product;
[MariaDB] How to create database and account
🇰🇷 Korean
2020.08.04 - [개발 창고/Database] - [MariaDB] Database 및 사용자 계정 생성
반응형