mariaDB(数据库)-安装配置和使用

本文详细介绍了如何通过`mysql_secure_installation`脚本对MariaDB进行安全配置,包括设置root用户密码、删除匿名用户、限制远程登录以及管理数据库权限。此外,还涉及了MySQL用户管理,如创建、修改密码和分配权限的过程。
摘要由CSDN通过智能技术生成

[root@system1 ~]# mysql_secure_installation #设置数据库

/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current

password for the root user. If you’ve just installed MariaDB, and

you haven’t set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none): #因为以前没密码,直接回车即可

OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

Set root password? [Y/n] y #是否设置root密码 —— y

New password: #自定义

Re-enter new password: # 自定义

Password updated successfully!

Reloading privilege tables…

… Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them. This is intended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] #是否删除匿名用户,默认回车即可

… Success!

Normally, root should only be allowed to connect from ‘localhost’. This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y #是否拒绝root远程登陆——y,这样就只能localhost登陆了

… Success!

By default, MariaDB comes with a database named ‘test’ that anyone can

access. This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] #删除测试数据库访问他,默认回车即可

  • Dropping test database…

… Success!

  • Removing privileges on test database…

… Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] #是否现在重新加载权限表,默认回车即可

… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

基本配置就完成了

mysql使用及常用命令


登陆mysql语法:

mysql -u用户名 -p当前密码 -h服务器的ip(客户端才需要指定ip,并且服务端需要配置)【登陆当前服务器,不需要-h】

记住:选项和后面的值是没有空格的

  • 不需要指定用户和么有密码直接输入mysql ,进入mysql的子系统:

在这里插入图片描述

在mysql中即可执行若干命令;

查看mysq详细

status

在这里插入图片描述

命令结尾说明

注:在mysql提示符下敲命令的时候,一般都要以; 或者\G结束,更多的时候使用 ;结束,\G一般用户格式化输出,如果没有以 ; 结束的话,系统就会认为命令没有完成,不执行。 凡事以#或者--开头的语句,都认为是注释。

  • ; 结尾

在这里插入图片描述

  • \G 结尾(会格式化并排版)

在这里插入图片描述

所以如果命令太长的话,可以任意的换行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值