[root@localhost mysql]# cat /etc/centos-release
centos linux release 7.5.1804 (core)
[root@localhost mysql]# mysql -v
mysql ver 15.1 distrib 5.5.60-mariadb, for linux (x86_64) using readline 5.1
yum install mariadb mariadb-server mariadb-libs mariadb-devel -y
檢查安裝結果
rpm -qa |grep mariadb
[root@localhost ~]# rpm -qa |grep mariadb
mariadb-5.5.60-1.el7_5.x86_64
mariadb-server-5.5.60-1.el7_5.x86_64
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-devel-5.5.60-1.el7_5.x86_64
啟動並設定開機自動啟動
systemctl start mariadb
systemctl status mariadb
systemctl enable mariadb
mariadb命令後邊一定要加;結尾
登入mariadb
mysql -u root -p
檢視都有哪些資料庫表mariadb [(none)]> show databases;
+--------------------+
| database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql的密碼都在mysql這個庫裡面,有一張表叫user,這裡管理了可以登陸資料庫的使用者
常用命令及示例!
use mysql; ##切換到mysql資料庫
show tables; ##顯示本資料庫有哪些表
select user,host,password from mysql.user; ##查詢mysql資料庫的user表
desc mysql.user; ##查詢user表結構
flush privileges; ##重新整理資料庫
建立乙個新的資料庫並對這個表做相應操作
以下操作包含了:建立乙個資料庫、切換到某資料庫、建立乙個表、插入表的兩種方法、更新一行資料、刪除一行資料
create database test;
use test;
create table linux(username varchar(15) not null,password varchar(15) not null);
insert into linux values ('xiaoming', 'xiaoliu');
insert into linux values ('xiaohong', '12346'), ('honghong', '12346');
update linux set `password` = '112233' where username = 'honghong'
delete from linux where `password`='112233'
高階命令,慎用@@@@#刪除資料庫
drop database 《資料庫名》;
#刪除表
drop table 表名;
yum -y install epel-release python-pip python-devel
yum clean all
pip install mycli
命令使用:
mycli #連線本機可以直接輸入命令後回車
mycli -h localhost -u root
mycli -h 192.168.0.61 -u root
這裡改的密碼跟本地登入的密碼不是乙個,雖然是乙個賬戶
允許所有ip使用root使用者遠端登入,並將密碼改為my-new-password
grant all privileges on *.* to 'root'@'%' identified by 'my-new-password' with grant option;
只允許192.168.0.*段的ip位址使用root使用者遠端登入,並將密碼改為my-new-password
grant all privileges on *.* to 'root'@'192.168.0.%' identified by 'my-new-password' with grant option;
#!/bin/bash
# mysql使用者名稱
db_user="root"
# mysql密碼
db_passwd="xiaoliu"
# 要備份的資料庫名稱
db_name="test"
# 備份位置
backup_dir="/home/mysqlbak"
# 檔名設定為時間格式
time="$(date +"%y%m%d%h%m%s")"
mysqldump -u$db_user -p$db_passwd $db_name > "$backup_dir/$db_name"_"$time.sql"
#備份test庫
#mysqldump -uroot -pxiaoliu test > "/home/test"_"$(date +"%y%m%d%h%m%s").sql"
#備份所有資料庫
#mysqldump -uroot -pxiaoliu --opt --all-databases > "/home/mysqlbak/all-databases"_"$(date +"%y%m%d%h%m%s").sql"
CentOS 7 安裝 配置
本例為 minimal iso 版本 centos 與 rhel 是同源,所以,在 centos 文件不足時,可以參考 rhel 的文件。本例子環境為 windows 可以使用 fedora liveusb creator 或者 ultraiso 等工具來把系統寫入 u盤,而後通過u盤啟動來安裝系統...
CentOS7 安裝配置 vsftpd
yum install y vsftpdvi etc vsftpd vsftpd.confanonymous enable no anonymous enable yes chroot local user yes 去掉前面的注釋 chroot list enable yes chroot list...
CentOS 7 安裝配置FTP
安裝vsftpd yum install y vsftpd編輯ftp配置檔案 vi etc vsftpd vsftpd.conf anonymous enable no anonymous enable yes chroot local user yes 去掉前面的注釋 chroot list en...