原文链接: 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