mariadb
1.配置yum完成后,安装mariadb服务 yum install mariadb -y
开启服务 systemctl start mariadb
修改配置文件 vim /etc/my.cnf (修改内容为:增加skip-networking=1)
重启服务 systemctl restart mariadb
2.mysql加密 mysql_secure_installtion
Enter current password for root(enter for none) 不需输入密码
Change the root password ?[Y/n] Y 是否设定数据库root密码?是
Remove anonymous users?[Y/n]Y 是否删除匿名用户访问权限?是
Disallow root login remotely?[Y/n] 是否禁止超级用户远程登录?是
Rmove test database and access to it?[Y/n] 是否删除测试数据?是
Reload privilege tables now?[Y/n] 是否重新加载服务?是
3.mysql的基本操作
(1)登录 mysql -uroot -pwestos(-u代表用户,-p代表密码)
(2)查询 显示数据库 show databases;
进入MySQL库 use mysql;
显示 数据库里表的名称 show tables;
查询user表中所有内容 select * from user;
查询user表的结构 desc user
(3)数据库的建立 建立westos库 create database westos;
查看 show database;
建立Linux表,并有username和password两个字段 create table linux( username varchar(15) not null,
password varchar(15) not null );
给Linux表中写入内容 insert into values ('user1' , '123') ;
查看 select * from linux;
(4)数据库的更新 更新加密user1 update linux set password=password('passwd2') where username='user1';
创建加密的user3
删除user1的密码 delete from linux where username='user1';
在Linux表最后添加age列 alter table linux add age varchar(4);
在Linux表中username字段后添加class字段 alter table linux add class varchar(4) after username;
删除age字段 alter table linux drop age;
(5)删除数据库 删除Linux表 drop table linux;
删除westos库 drop database westos;
建立westos库 mysql -uroot -pwestos -e "create database westos";
导入数据到westos库 mysql -uroot -pwestos westos < /mnt/linux.sql
(5)用户授权 创建用户Lee,只能通过本机登录 create user [email protected] identified by 'lee';
创建用户Lee,通过网络登录 create user [email protected]'%' identified by 'lee';
用户授权 grant insert,update,delete,select on westos.linux to [email protected];
删除用户授权 revoke delete on westos.linux from [email protected];
删除用户 drop user [email protected]'%';
(6)修改密码 mysqladmin -uroot -pwestos password lee
开启MySQL登录忽略授权表 mysql_safe --skip-grant-table &
过滤MySQL进程并结束 ps aux | grep mysql;
kill -9+参数;
更新root密码 update mysql.user set Password=password('123') where User='root';