Mysql数据库

来源:互联网 发布:ubuntu 重装ssh 编辑:程序博客网 时间:2024/05/29 17:30

1、配置mariadb

yum install mariadb-server.x86_64 -y systemctl start mariadb systemctl enable mariadb netstat -antlpe | grep mysql 

在/etc/my.cnf中添加skip-networking=1 #禁止远程登陆
2、命令

show databases;         #显示数据库 user mysql;             #进入mysql数据库 show tables;           #显示库里的表 desc table;            #显示表的描述 select * from tableselect * from table where Host=‘127.0.0.1‘mysql -uroot -predhat -e “show databases”
create database nono;##创建数据库 use nono; create table Linux ( username varchar(30) not null, password varchar(30) not null, age varchar(3) ); ##创建表 insert into linux values (‘nono’,’123’,’25’); ##添加表内容,字段的内容可以为空,但是不能少
alter table linux rename message; 修改表名 alter table linux add class varchar(50); alter table linux add class varchar(50) after password; ##在password字段后添加class字段 alter table linux drop class; ##删除class字段 update linux set class=’linux’; ##修改linux表class字段为linux update linux set class=’Java’ where username=” and password=”; 
delete from linux where username=‘‘ and class=‘‘;##删除表中内容 drop table linux;##删除表 drop database nono;##删除数据库
mysqldump -uroot -predhat nono > /mnt/mj.sql mysql -uroot -p drop database nono; mysql -uroot -predhat -e “create database nono;” ##创建数据库nonomysql -uroot -predhat nono < /mnt/mj.sql

备份

systemctl stop mariadb mysqld_safe –skip-grant-tables & ##j进入安全模式 mysql -uroot use mysql; update user set Password=password(‘redhat’) where User=’root’; ps aux | grep mysql kill -9 3368 kill -9 3526 systemctl restart maruidb 

授权

create user client@localhost indentified by 'nono'create user nono@'%' identified by 'redhat'grant insert, update, delete on mariadb.* to client@localhostgrant select on mariadb.*nono@'%'flush privilegesshow grants for client@localhostrevoke delete, update on mariadb.*from client@localhostdrop user client@localhost

安装phpmyadmin

yum install httpd -y tar jxf phpMyAdmin-3.4.0-1-all-languages.tar.bz2 -C/var/www/html mv phpMyAdmin-3.4.0-1-all-languages mysqladmin cd mysqladmin cp config.sample.inc.PHP config.inc.php less Documentation.txt vim config.inc.php yum install php php-mysql -y systemctl restart httpd firewall-config firewall-cmd --list-all