溫馨提示×

溫馨提示×

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

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

maridb

發布時間:2020-08-06 10:38:25 來源:網絡 閱讀:654 作者:漂浮的天堂 欄目:數據庫

Maridb

yum intall mariadb-server -y  ##安裝mariadb服務

systemctl start mariadb    ##開啟服務



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

maridb

 systemctl  restart  mariadb  #重啟服務


 mysql_secure_installtion   ##mysql加密


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

Change the root password? [Y/n] y  ##是否設定數據庫root密碼

New password:               ##輸入密碼

Re-enter new password:         ##重復密碼

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

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

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

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

maridb

數據庫的基本sql語句操作

   (1)登錄

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

maridb

    (2)查詢

    show databases;     ##顯示數據庫

    use mysql;        ##進入mysql庫

maridb

     show tables;       ##顯示數據庫里表的名稱


     select * from user;    ##查詢user表中所有內容

maridb

     desc linux;          ##查詢表的結構 (顯示表頭)

maridb

   (3)數據庫的建立

     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表里寫入內容

maridb

   (4)數據庫的更新

    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)刪除數據庫

     drop table linux    ##刪除Linux表

maridb

     drop database westos   ##刪除westos庫


   (6)數據庫的備份

     mysqldump -u root -p123 --all -database  ##備份表中所有數據

maridb

     mysqldump -u root -p123 --all -database --no-data  ##備份所有表,不備份數據

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  ##導入數據到westos庫

maridb



   (7)用戶授權

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

    create user ggg@'%' identified by 'ggg';     ##創建用戶ggg,只能通過網絡登錄

    grant insert,update,delete,select on westos.linux to ggg@localhost  ##用戶授權

maridb

     revoke delete on westos.linux from ggg@localhost   ##刪除用戶授權

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

maridb

    (8)修改密碼

      mysqladmin -uroot -predhat password 123

     mysqld_safe --skip-grant-table &  ##開啟MySQL登錄接口忽略授權表

     mysql               ##不要密碼登錄


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

     ps aux | grep mysql ##過濾mysql進程并結束

     kill -9   mysqlpid    

     systemctl start maraidb   ##重啟MySQL

maridb

    3.數據庫網頁管理工具

     yum install httpd php phy-mysql -y  ##安裝服務

   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  ##復制模板

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

修改配置文件內容

maridb、

   systemctl restart httpd  

訪問http://172.25.254.117/mysqladmin

ctrl+shift+delete   ##清除緩存

maridb

maridb

maridb

maridb

maridb


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女