日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

进入mariadb_MariaDB基本命令

發(fā)布時間:2023/12/20 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 进入mariadb_MariaDB基本命令 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

MariaDB名稱來自Michael Widenius的女兒Maria的名字。MariaDB數(shù)據(jù)庫管理系統(tǒng)是MySQL的一個分支,主要由開源社區(qū)在維護,采用GPL授權(quán)許可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能輕松成為MySQL的代替品。

1. 數(shù)據(jù)庫安裝并初始化

yum install mariadb-server.x86_64 -y ##安裝數(shù)據(jù)庫

systemctl start mariadb ##開啟數(shù)據(jù)庫服務(wù)

netstat -antlupe|grep mysql ##查看數(shù)據(jù)庫的接口信息

mysql ##測試能否打開數(shù)據(jù)庫

vim /etc/my.cnf ##關(guān)閉數(shù)據(jù)庫對外接口

skip-networking=1 ##在第6行添加命令(跳過網(wǎng)絡(luò)服務(wù))

:wq

systemctl restart mariadb ##重啟服務(wù)

netstat -antlupe|grep mysql ##此時查看數(shù)據(jù)庫端口已經(jīng)關(guān)閉

mysql_secure_installation ##數(shù)據(jù)庫初始化,這里我們輸入密碼后全部選擇y

2. MYSQL基本操作指令

mysql -uroot -p123 ##進入數(shù)據(jù)庫(這里不要養(yǎng)成習(xí)慣因為輸入密碼時明文的)

1)查看****重點內(nèi)容

show databases; ##顯示數(shù)據(jù)庫

use mysql; ##進入數(shù)據(jù)庫

show tables; ##顯示數(shù)據(jù)庫中的表

select * from mysql.user; ##查詢mysql庫下的user表中的數(shù)據(jù)

desc user; ##查看user表的數(shù)據(jù)結(jié)構(gòu)

flush privileges; ##刷新數(shù)據(jù)庫信息

select host,user,password from user; ##查詢user表中的host,user,password字段

select host,user,password from user where host="::1"##查詢表中字段中有關(guān)::1的數(shù)據(jù)

2)創(chuàng)建

create database westos; ##創(chuàng)建westos數(shù)據(jù)庫

use westos; ##進入westos數(shù)據(jù)庫

create table linux( ##創(chuàng)建表,user,passwd字段

user varchar(15) not null,

passwd varchar(15) not null ##varchar可變型字符變量

);

insert into linux values ('student','student'); ##在linux表中插入值為student student

select * from linux; ##查詢linux中的數(shù)據(jù)

3)更改

alter table linux rename messages; ##將linux表重命名為messages

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

ALTER TABLE linux ADD age VARCHAR(5)

update linux set password=student where username=student;##更新linux表中user1的密碼為password2

4)刪除

delete from linux where username=user1; ##刪除linux表中user1的所有內(nèi)容

drop table linux; ##刪除linux表

drop database westos; ##刪除westos數(shù)據(jù)庫

5)用戶授權(quán)

CREATE USER lee@localhost identified by 'lee'; ##創(chuàng)建用戶lee密碼為lee

grant select insert on *.* to lee@localhost; ##授權(quán)user1 密碼為passwd1只能在本地 查詢數(shù)據(jù)庫的所以內(nèi)容

grant all on mysql.* to lee@'%' identified by 'lee2'; ##授權(quán)user2 密碼為passwd2 可以從遠程任意主機登錄mysql 并且可以對mysql數(shù)據(jù)庫任意操作

show grants for lee@localhost; ##查看已經(jīng)修改的權(quán)限;

revoke insert on *.* from lee@localhost; ##刪除掉用戶lee的添加數(shù)據(jù)權(quán)限;

6)備份

/var/lib/mysql

mysqldump -uroot -p123 westos > /mnt/mysql.sql ##備份mysql庫到mysql.bak

mysql -uroot -p123 -e "DROP database westos"

mysql -uroot -p123 westos < /mnt/mysql.sql ##恢復(fù)mysql.bak 到westos庫

7)mysql 密碼恢復(fù)

/etc/init.d/mysqld stop

或者systemctl stop mariadb

mysqld_safe --skip-grant-tables & ##跳過grant-tables授權(quán)表 不需要認證登錄本地mysql數(shù)據(jù)庫

update mysql.user set password=password('westos') where user='root'; ##更新mysql.user 表中條件為root用戶的密碼為加密westos

修改完成后

ps aux|grep mysql

kill -9 +端口號 結(jié)束所有關(guān)于mysql的進程

systemctl start mysql

3. php-mysq

@@php -m 可以查看php所支持的服務(wù),因為本身默認不支持mysql

所以需要安裝php-mysql模塊才能使用@@

phpmyadmin

yum install php php-mysql httpd mysql mysql-server ##安裝需要的服務(wù)

tar jxf phpmyadmin-*.tar.bz2 -C /var/www/html ##將下載好的東西解壓

mv phpmyadmin phpadmin ##重命名

cp config.sample.inc.php config.inc.php ##復(fù)制文件

vim config.inc.php ##php3.4版本不需要

add

$cfg['blowfish_secret'] = 'test';

/etc/init.d/httpd start

測試:http://172.25.254.117/phpadmin

4. discuz論壇建立

下載DISCUZ壓縮包

unzip解壓

cp -r upload /var/www/html/

chomd 777 /var/www/html/upload/* -R

測試:http://172.25.254.117/upload

總結(jié)

以上是生活随笔為你收集整理的进入mariadb_MariaDB基本命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。