萌新的linux之旅21
mariadb
1、安装mariadb
yum install mariadb-server.x86_64 -y ##安装mariadb数据库
2、数据库安全设置
netstat -antple | grep mysql ##查看网络端口是否打开
vim /etc/ym.cnf ##编辑配置文件
skip-networking=1 ##关闭网络端口
mysql_secure_installation ##设置登陆密码
mysql -uroot -p ##登陆数据库
查询
show databases; 查看有的库
use mysql ; 进入mysql这个库
show tables ; 列出mysql的所有表
desc user ; user表的结构
select * from user; 查询语句 *所有字段
2增加
create database hehe ;
use hehe;
create table linux (
username varchar(66) not null;
password varchar(66) not null;
age varchar(20) );
insert into hehe values (‘oidlee’,’qwe’,”);
insert into hehe values (‘lee’,’123’,’30’);
MariaDB [westos]> select * from hehe;
3.修改
修改表的名字
alter table hehe rename message;
alter table hehe add class varchar(66); 添加属性
alter table hehe add class varchar(66) after password; 在password之后添加属性
alter table hehe drop class; 删除
update hehe set class=’linux’; 改这一列的所有属性
update hehe set class=’linux’ where username=’oldlee’;改一行中的名字为oldlee的属性
4.备份
mysqldump -uroot -predhat hehe > /mnt/hehe.sql
mysql -uroot -pwestos -e “create database hehe;”
mysql -uroot -pwestos hehe < /mnt/hehe.sql
5.删除
delete from text where username=’oldlee’ and class=’linux’;
drop table text;
drop database hehe;
忘记数据库密码:
systemctl stop mariadb.service
mysqld_safe –skip-grant-tables & ##开启数据库软件,不启动授权表 & 进程打入后台
mysql
进入数据库更新密码
update user set Password=password(‘redhat’) where User=’root’;
ps aux | grep mysql
kill -9 数据库进程
systemctl restart mariadb
6.添加用户,添改权限
‘%’表示任何地方登陆
授权表默认自动刷新。改完没作用,手动刷新
create user [email protected] identified by ‘haha’;
创建新用户
grant delete drop on haha.* to [email protected];
添加权限
show grants for [email protected];
查看单独用户权限
revoke delete drop on haha.* from [email protected];
删除权限
drop user [email protected];
删除用户
7.mysql图形管理工具 phpmyadmin
yum install httpd -y
tar jxf phpMyAdmin… #解压
mv mysqladmin #重命名
less README 发现要查看当前文件中的 Documentation.txt
less Documentation.txt 发现需要修改文件,还要添加信息
cp config.sample.inc.php config.inc.php
vim config.inc.php
$cfg[‘blowfish_secret’] = ‘ba17c1ec07d65003’; 里面的字符不可以随便写
做完之后,发现系统对文件无法解释,需要安装php相应软件
yum install php php-mysql -y
systemctl restart httpd
systemctl stop firewalld
测试:
http://172.25.254.110/mysqladmin
因为是最简单的安装,所以显示缺少扩展,这里不需要,直接进入就可以