溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

maridb

發(fā)布時間:2020-08-06 10:38:25 來源:網(wǎng)絡(luò) 閱讀:639 作者:漂浮的天堂 欄目:數(shù)據(jù)庫

Maridb

yum intall mariadb-server -y  ##安裝mariadb服務(wù)

systemctl start mariadb    ##開啟服務(wù)



vim /etc/my.cnf     ##修改配置文件

maridb

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


 mysql_secure_installtion   ##mysql加密


Enter current password for root (enter for none):   ##數(shù)據(jù)庫原始密碼,直接回車

Change the root password? [Y/n] y  ##是否設(shè)定數(shù)據(jù)庫root密碼

New password:               ##輸入密碼

Re-enter new password:         ##重復(fù)密碼

Remove anonymous users? [Y/n] y  ##是否刪除匿名用戶訪問權(quán)限

Disallow root login remotely? [Y/n] y  ##是否禁止超級用戶遠程登錄

Remove test database and access to it? [Y/n] y   ##是否刪除測試數(shù)據(jù)

Reload privilege tables now? [Y/n] y     ##重新加載服務(wù)

maridb

數(shù)據(jù)庫的基本sql語句操作

   (1)登錄

    mysql -uroot -p    ##-u代表用戶  -p密碼

maridb

    (2)查詢

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

    use mysql;        ##進入mysql庫

maridb

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


     select * from user;    ##查詢user表中所有內(nèi)容

maridb

     desc linux;          ##查詢表的結(jié)構(gòu) (顯示表頭)

maridb

   (3)數(shù)據(jù)庫的建立

     create database westos;     ##建立westos庫

    create table linux(        ##建立Linux表,并且有username和password兩個字段

maridb

     username varchar(15) not null,

     password varchar(15) not null

     ); 

maridb

     insert into linux values ('user1','123')   ##給Linux表里寫入內(nèi)容

maridb

   (4)數(shù)據(jù)庫的更新

    update linux set password=password('456') where username='user1';  ##加密更新user1密碼

    update linux set password=password('456') where (username='user2' or username='user3';  ##更新user2和user3密碼

maridb

maridb

maridb

    delete from linux where where username='user1';  ##刪除user1密碼

maridb

alter table linux add age varchar(4);     ##在Linux表最后添加age列

alter table linux add year varchar(4)after age ##在age字段后添加year字段

alter table linux drop age ;   ##刪除age字段

maridb

   (5)刪除數(shù)據(jù)庫

     drop table linux    ##刪除Linux表

maridb

     drop database westos   ##刪除westos庫


   (6)數(shù)據(jù)庫的備份

     mysqldump -u root -p123 --all -database  ##備份表中所有數(shù)據(jù)

maridb

     mysqldump -u root -p123 --all -database --no-data  ##備份所有表,不備份數(shù)據(jù)

maridb

     mysqldump -u root -p123 westos    ##備份westos庫

     mysqldump -u root -p123 westos > /mnt/westos.sql  ##備份westos庫保存到westos.sql

     mysqldump -u root -p123 westos linux > /mnt/linux.sql  ##備份westos庫中的Linux表

maridb

     mysql -u root -p123 -e "create database westoss;"  ##建立westos庫

     mysql -u root -p123 westos <  /mnt/linux.sql  ##導(dǎo)入數(shù)據(jù)到westos庫

maridb



   (7)用戶授權(quán)

    create user ggg@localhost identified by 'ggg';  ##創(chuàng)建用戶ggg,只能通過本機登錄

    create user ggg@'%' identified by 'ggg';     ##創(chuàng)建用戶ggg,只能通過網(wǎng)絡(luò)登錄

    grant insert,update,delete,select on westos.linux to ggg@localhost  ##用戶授權(quán)

maridb

     revoke delete on westos.linux from ggg@localhost   ##刪除用戶授權(quán)

    drop user ggg@'%'   ##刪除用戶

maridb

    (8)修改密碼

      mysqladmin -uroot -predhat password 123

     mysqld_safe --skip-grant-table &  ##開啟MySQL登錄接口忽略授權(quán)表

     mysql               ##不要密碼登錄


     update mysql.user set Password=password('123') where User='root'  ##更新root密碼

     ps aux | grep mysql ##過濾mysql進程并結(jié)束

     kill -9   mysqlpid    

     systemctl start maraidb   ##重啟MySQL

maridb

    3.數(shù)據(jù)庫網(wǎng)頁管理工具

     yum install httpd php phy-mysql -y  ##安裝服務(wù)

   systemctl start httpd

   systemctl enable httpd

   systemctl stop firewalld

   systemctl disable firewall

  

   tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 -C /var/www/html ##解壓文件到指定目錄

maridb

   mv  phpMyAdmin-3.4.0-all-languages/ mysqladim  ##重命名文件


   cd mysqladim

   cp -p config.sample.inc.php  config.inc.php  ##復(fù)制模板

   vim  config.inc.php  ##編輯配置文件

修改配置文件內(nèi)容

maridb、

   systemctl restart httpd  

訪問http://172.25.254.117/mysqladmin

ctrl+shift+delete   ##清除緩存

maridb

maridb

maridb

maridb

maridb


向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI