In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about what MariaDB management commands are about. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
MariaDB Management Command 1. View the installed version of MariaDB
To view the current version of the installed database, enter the following command in the terminal:
$mysql-version
This command will tell you the current version of the database. You can also run the following command to view the details of the version:
$mysqladmin-u root-p version2, log in to MariaDB
To log in to the MariaDB server, run:
$mysql-u root-p
Then enter the password to log in.
3. List all databases
To list all the databases currently owned by MariaDB, run after you log in to MariaDB:
> show databases
LCTT Note: $here represents the prompt of shell, > here represents the prompt of MariaDB shell. )
4. Create a new database
Create a new database in MariaDB, log in to MariaDB and run:
> create database dan
To create a database directly on the terminal, run:
$mysqladmin-u user-p create dan
Here, dan is the name of the new database.
5. Delete the database
To delete the database, run in a logged-in MariaDB session:
> drop database dan
In addition, you can also run
$mysqladmin-u root-p drop dan
Note: if you prompt for a "access denied" error when running the mysqladmin command, it should be because we do not authorize root. To authorize root, please refer to the point 7 method, just change the user to root.
6. Create a new user
To create a new user for the database, run:
> CREATE USER 'dan'@'localhost' IDENTIFIED BY' password';7, authorizing users to access a database
To authorize a user to access a database, run:
> GRANT ALL PRIVILEGES ON test.* to 'dan'@'localhost'
This gives the user dan full access to the database named test. We can also limit users to only SELECT, INSERT, and DELETE permissions.
To grant access to all databases, replace test with *. Like this:
> GRANT ALL PRIVILEGES ON *. * to 'dan'@'localhost';8, backup / export database
To create a backup of a single database, run the following command in the terminal window
$mysqldump-u root-p database_name > db_backup.sql
To create backups of multiple databases at once, run:
$mysqldump-u root-p-- databases db1 db2 > db12_backup.sql
To export more than one database at a time, run:
$mysqldump-u root-p-- all-databases > all_dbs.sql9, restore database from backup
To restore the database from a backup, run:
$mysql-u root-p database_name
< db_backup.sql 但这条命令成功的前提是预先没有存在同名的数据库。如果想要恢复数据库数据到已经存在的数据库中,则需要用到 mysqlimport 命令: $ mysqlimport -u root -p database_name < db_backup.sql10、更改 MariaDB 用户的密码 本例中我们会修改 root 的密码,但修改其他用户的密码也是一样的过程。 登录 MariaDB 并切换到 'mysql' 数据库: $ mysql -u root -p>Use mysql
Then run the following command:
> update user set password=PASSWORD ('your_new_password_here') where User='root'
Next, reload permissions:
> flush privileges
Then exit the session.
Thank you for reading! This is the end of this article on "what are the MariaDB management commands?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.