####數據庫####
1.安裝數據庫
yum install mariadb-server.x86_64 -y
2.查看網絡端口
netstat -antlpe | grep mysql
vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
skip-networking=1 ##添加這一行
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
3.修改數據庫的密碼
mysql_secure_installation
systemctl restart mariadb
mysql -uroot -p 從本機登錄mysql數據庫
show databases; 顯示數據庫
use mysql; 進入數據庫
desc user; 查看user表的數據結構
flush privileges; 刷新數據信息
select host,user,password from user; 查詢user表中的host,user,password字段
create database westos; 創建westos數據庫
use westos;
create table linux(
username varchar(15) not null,
password varchar(15) not null
);
select * from mysql.user; 查詢mysql庫下的user表數據
alter table linux add age varchar(4); 查詢age字段到linux表中
ALTER TABLE linux DROP age 刪除age字段
ALTER TABLE linux ADD age VARCHAR(5) AFTER name 在name字段後添加字段age
show tables;
desc linux;
insert into linux values ('user1','passwd1'); 在linux表中插入值爲username = user1,password = password1
uplete linux set password=password('passwd2') where username=user1; 更新linux表中user1的密碼爲password2
delete from linux where username=user1; 刪除linux表中user1的所有內容
grant select on *.* to user@localhost identified by 'passwd1';
授權user1 密碼爲passwd1 並且只能在本地 查詢數據庫的所有內容
4.用戶和訪問權限
創建用戶
CREATE USER wxh@localhost identified by 'westos'; ##密碼爲westos
CREATE USER lee@'%'identified by 'redhat';
用戶授權
GRANT INSERT,UPDATE,DELETE,SELECT on *.* to USER westos@localhost;
重載授權表
FLUSH PRIVILEGES;
查看用戶授權
SHOW GRANTS FOR wxh@localhost;
撤銷用戶權限
REVOKE DELETE,INSERT,UPDATE on *.* from wxh@localhost;
刪除用戶
DROP USER wxh@localhost;
yum install mysql mysql-server
mysqladmin -uroot -predhat password westos 修改本地mysql root密碼
mysqladmin -uroot -predhat -h 192.168.0.188 password westos 修改遠程192.168.0.188 mysql服務器 root密碼
mysql_secure_installation 第一次安裝mysql以後通過這條命令可以對mysql進行設置
mysql -uroot -predhat 從本機登錄mysql數據庫
5.忘了數據庫密碼怎麼辦?
mysqld_safe --skip-grant-tables & 跳過grant-tables授權表 不需要認證登錄本地mysql數據庫
update mysql.user set password=password('westos') where user='root'; 更新mysql.user 表中條件爲root用戶的密碼爲加密westos
mysql -uroot
fg
killall -9 mysqld_safe
ps aux | grep mysql
systemctl start mysql
systemctl start mariadb
mysql -uroot -predhat
5.備份與恢復
備份
mysqldump -uroot -predhat westos > westos.dump
mysqldump -uroot -predhat --all-databases > backup.dump
mysqldump -uroot -predhat --no-data westos> westos.dump
恢復
mysqladmin -uroot -predhat create db2
mysql -urooot -predhat db2 < westos.dump
備份
/var/lib/mysql
mysqldump -uroot -predhat mysql > mysql.bak 備份mysql庫到mysql.bak
mysql -uroot -predhat westos < mysql.bak 恢復mysql.bak 到westos庫
6.圖形mysql
phpmyadmin
yum install php php-mysql httpd mysql mysql-server
tar jxf phpmyadmin-*.tar.bz2 -C /var/www/html
mv phpmyadmin phpadmin
cp config.sample.inc.php config.inc.php
vim config.inc.php
add
------------------------------
$cfg['blowfish_secret'] = 'test';
------------------------------
三.數據庫
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Spring Security視頻地址
joseph999
2019-02-23 13:24:27
本地終端無法登陸系統故障
Edwin_
2019-02-22 23:43:51
AIX 用戶鎖定
gaofengkun
2019-02-22 23:13:00
使用HttpClient做請求響應中轉
rr57ca2a52cbe97
2019-02-22 22:33:33
Samba服務器配置
miaoxinwen
2019-02-22 21:54:31
Linux源碼包的安裝
miaoxinwen
2019-02-22 21:54:27
Linux 3.13 smack 源代碼
nebular_railgun
2019-02-22 21:51:18
tcpdump
zhangxiaocen
2019-02-22 21:47:37
sshpass: 用於非交互的ssh 密碼驗證
gxjluck
2019-02-22 21:27:12
Xcode 升級後,常常遇到的遇到的警告、錯誤,解決方法
胃搏天
2019-02-23 00:40:03
22Python標準庫系列之Redis模塊
Adlereden
2019-02-22 22:23:10
POJ 3597 Polygon Division:題目解答源碼
yoyqiang
2019-02-22 21:36:22