首页 > 数据库 >linux中mariadb基本用法详解(企业级)_sql_19

linux中mariadb基本用法详解(企业级)_sql_19

时间:2023-05-03 23:57:56浏览次数:47  
标签:19 linux mysql 企业级 详解 用法 sql mariadb

原文链接: linux中mariadb基本用法详解

数据库
表的每一个列名字的头 叫做字段
是高级的exel表格软件

数据库种类
sqlserver sqllite db2
oracle > mysql 比较多

其中mysql 分支中有一个 mariadb

yum install mariadb-server -y
systemctl start mariadb

linux中mariadb基本用法详解(企业级)_sql

mysql_secure_installation
设定密码

linux中mariadb基本用法详解(企业级)_sql_02

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] ##是否要设定数据库超级用户密码
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] ##是否禁止超级用户通过远程登陆
... 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 -uroot -p
登陆

linux中mariadb基本用法详解(企业级)_mysql_03

去掉端口
netstat -antlupe |grep mysql

linux中mariadb基本用法详解(企业级)_mysql_04

vim /etc/my.cnf.d

skip-networking=1

linux中mariadb基本用法详解(企业级)_mysql_05

systemctl restart mariadb.service

就去掉了端口

数据库管理

mysql -uroot -p

show databases; (不区分大小写)

linux中mariadb基本用法详解(企业级)_mysql_06

use mysql; 进去库 一定要用分号结尾

linux中mariadb基本用法详解(企业级)_linux_07

show tables; 看到里面的东西

linux中mariadb基本用法详解(企业级)_linux_08

select * from user 查看user库中的所有东西

linux中mariadb基本用法详解(企业级)_sql_09

select Host,User,Password from user 选择字段查看部分内容

create database westos; 建立库

linux中mariadb基本用法详解(企业级)_sql_10

mysql -uroot -p

show databases ;

linux中mariadb基本用法详解(企业级)_mysql_11

use westos ;

linux中mariadb基本用法详解(企业级)_sql_12

create table linux (

-> username varchar(10) not null, 长度十个字节不能为空

-> password varchar(50) not null

-> );

这样就可以

desc linux; 查看表的结构

insert into linux values ('lee','123');

select * from linux 就可以看到了

linux中mariadb基本用法详解(企业级)_linux_13

linux中mariadb基本用法详解(企业级)_mysql_14

这样就可以插入数据了

修改

alter table linux rename userdata ;

linux中mariadb基本用法详解(企业级)_linux_15

将表linux改名为 userdata

表中继续增加字段

alter table linux add age varchar(4);

linux中mariadb基本用法详解(企业级)_linux_16

默认在表中最后添加

alter table linux drop age;

linux中mariadb基本用法详解(企业级)_sql_17

删除 age

alter table linux add age varchar(4) after username ;

添加到 username 之后 不是最后一列

linux中mariadb基本用法详解(企业级)_linux_18

update linux set age='20' ;

都会改称 20岁

linux中mariadb基本用法详解(企业级)_sql_19

©著作权归作者所有:来自51CTO博客作者mb63774a171e569的原创作品,请联系作者获取转载授权,否则将追究法律责任
linux中mariadb基本用法详解(企业级)
https://blog.51cto.com/u_15883840/5870005

标签:19,linux,mysql,企业级,详解,用法,sql,mariadb
From: https://www.cnblogs.com/ygst/p/17369920.html

相关文章

  • [极客大挑战 2019]HardSQL,wp
    一:分析既然说了是HardSQL,肯定就不是万能密码这种简单的了1.首先判断字符型还是数字型我们首先输入payload:username=admin'--+&password=1发现好像有什么被过滤掉了。然后检查过滤符号,这里可以直接用bp爆破看看过滤了哪些字符,也可以简单测试一下这里我猜测过滤了空格, 然......
  • Python flask-sqlalchemy
    安装pip3installmysql-connector-pythonpipinstallflask_sqlalchemy /setting.pyclassConfigs:#数据库信息MYSQL_USER=''MYSQL_PWD=''MYSQL_HOST=''MYSQL_PORT=''DBNAME=''......
  • mysql忘记密码
    在忘记MySQL密码的情况下,可以通过--skip-grant-tables关闭服务器的认证,然后重置root的密码,具体操作步骤如下。步骤1):关闭正在运行的MySQL服务。打开cmd进入MySQL的bin目录。步骤2):输入mysqld--console--skip-grant-tables--shared-memory命令。–skip-gr......
  • GUID转换成16位、19位、22位唯一字符串
    ///<summary>///依据GUID获取16位的唯一字符串///<paramname=\"guid\"></param>///<returns></returns>publicstaticstringGuidTo16String(){longi=1;......
  • 解决MySQL自动弹出命令行窗口
    自从装了MySQL之后,我的电脑就会在某些时刻弹出一个黑乎乎的命令行窗口,然后立马消失。一开始还以为是电脑出了什么故障,但一直没有出现其他什么问题,就是玩游戏时弹出来有点难受。有一次我眼睛看到了一闪而过的窗口有MySQL几个字,就确定了是MySQL的原因。于是上网找解决方法,找到了一......
  • mysql优化参数
    --隔离级别select*from`performance_schema`.variables_by_threadwherevariable_name='transaction_isolation';--全局级别和回话级参数作用于setsessionbinlog_rows_query_log_events=on;setGLOBALbinlog_rows_query_log_events=on;--缓冲区大小setgloba......
  • 从0开始构建一个Oauth2Server服务 <19> Token 编解码
    Token编解码令牌提供了一种通过在令牌字符串本身中编码所有必要信息来避免将令牌存储在数据库中的方法。这样做的主要好处是API服务器能够验证访问令牌,而无需对每个API请求进行数据库查找,从而使API更容易扩展。OAuth2.0BearerTokens的好处是应用程序不需要知道您决定如......
  • 举一个数据库死锁的例子,MySQL 怎么解决死锁?
    转载:https://juejin.cn/post/7072000882128191518分析&回答在数据库中有两种基本的锁类型:排它锁(ExclusiveLocks,即X锁)和共享锁(ShareLocks,即S锁)。当数据对象被加上排它锁时,其他的事务不能对它读取和修改。加了共享锁的数据对象可以被其他事务读取,但不能修改。数据库利用这两种基......
  • mysql -- 事件
    MySQL的EVENTS是用来处理计划任务的。MySQL使用称为事件调度线程的特殊线程来执行所有预定事件。默认情况下,事件调度线程是未启用(版本低于8.0.3)的状态,如要启用它,可以执行以下命令:>SETGLOBALevent_scheduler=ON;>showvariableslike'%event_scheduler%';+-----------......
  • SQL的组成包括哪些部分?
    (1)数据定义语言DDL 用于定义和管理对象,例如数据库,数据表,视图 create,drop,alert (2)数据操作语言DML 用于操作数据库对象所包含的数据 insert,update,delete (3)数据查询语言DQL 用于查询数据库对象所包含的数据 select (4)数据控制语言DCL 用于控制对数据库对象操作的权限 grant,re......