欢迎投稿

今日深度:

mariadb 的查询、创建、修改、备份、删除、重置密

mariadb 的查询、创建、修改、备份、删除、重置密码、授权、mysql的图形管理工具phpmyadmin,mariadbphpmyadmin


1.查询
[root@localhost ~]# mysql -uroot -p ##进入数据库
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.35-MariaDB MariaDB Server
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> show databases; ##查询库

MariaDB [(none)]> use mysql ##使用库

MariaDB [mysql]> show tables; ##查询表格

MariaDB [mysql]> select * from user;##查询表格信息

MariaDB [mysql]> select * from user where Host=’127.0.0.1’;


MariaDB [(none)]> quit ##退出数据库
2.创建
MariaDB [(none)]> create database westos; ##创建westos 库

MariaDB [(none)]> show databases; ##查询库

MariaDB [(none)]> use westos; ##使用westos库

MariaDB [westos]> show tables; ##查询表格

MariaDB [westos]> create table linux (
-> username varchar(50) not null,
-> password varchar(50) not null,
-> age varchar(4) ); ##创建表格

MariaDB [westos]> desc linux; ##查询表格结构

MariaDB [westos]> insert into linux values (‘hu’,’123’,’20’); ##插入表格信息

MariaDB [westos]> select * from linux; ##查询表格信息

3.修改
alter table linux rename message; ##重命名表格名

alter table message add class varchar(50); ##在message表格中添加class字段

alter table message drop class; ##删除message表格里的class字段

alter table message add class varchar(50)after password; ##在password后添加class字段

update message set class=’linux’;

update message set class=’java’ where age=’20’;

4.备份
mysqldump -uroot -pwestos westos > /mnt/westos.sql ##将westos数据库里的信息导入到/mnt/westos,sql

mysql -uroot -pwestos -e “drop database westos;” ##删除westos库
mysql -uroot -pwestos -e “create database westos;” ##添加westos库

mysql -uroot -pwestos westos < /mnt/westos.sql


5.删除
delete from message where username=’hu’; ##删除message表格里username=’hu’的字段

drop table message; ##删除message表格

drop database westos; ##删除westos库

6.重置密码
知道原来的密码,重置密码
mysqladmin -uroot -pwestos password student

忘记原来的密码,重置密码
systemctl stop mariadb
mysqld_safe –skip-grant-tables &

mysql ##进入数据库更新密码
use mysql

update user set Password=password(‘westos’) where User=’root’; ##重置密码

ps aux | grep mysql ##查看正在运行的mysql进程

kill -9 进程号 ##停止正在运行的mysql进程

systemctl start mariad ##启动数据库
mysql -uroot -pwestos ##使用更改后的密码登陆数据库

7.授权
create user student@localhost identified by ‘student’; ##添加用户student

show grants for student@localhost; ##查看用户student的权限

grant select on mysql.* to student@localhost; ##给student授查看mysql库的权限

测试授权是否成功
mysql -ustudent -pstudent ##用student用户登录数据库
select * from mysql.user;

grant drop on westos.* to student@localhost; 授予student删除mysql库的权限


测试授权是否成功
mysql -ustudent -pstudent
drop database westos;

revoke select on mysql.* from student@localhost; #移除student用户查看westos库的权限

测试移除权限是否成功
mysql -ustudent -pstudent
select * from mysql.user;

8.mysql的图形管理工具phpmyadmin
获取phpMyAdmin-3.4.0-all-languages.tar.bz2 压缩包
lftp 172.25.254.250
get phpMyAdmin-3.4.0-all-languages.tar.bz2

tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 -C /var/www/html ##解压到/var/www/html

mv phpMyAdmin-3.4.0-all-languages mysqladmin ##重命名

less Documentation.txt

cp config.sample.inc.php config.inc.php
vim config.inc.php

yum install httpd php php-mysq -y ##安装http,php php-mysq


systemctl start httpd ##启动http
systemctl stop firewall ##关闭火墙
测试:
浏览器中输入http://172.25.254.106/mysqladmin

www.htsjk.Com true http://www.htsjk.com/mariadb/20677.html NewsArticle mariadb 的查询、创建、修改、备份、删除、重置密码、授权、mysql的图形管理工具phpmyadmin,mariadbphpmyadmin 1.查询 [root@localhost ~]# mysql -uroot -p ##进入数据库 Enter password: Welcome to the MariaDB m...
相关文章
    暂无相关文章
评论暂时关闭