溫馨提示×

溫馨提示×

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

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

linux 筆記3-8 mysql

發(fā)布時間:2020-04-11 11:01:02 來源:網(wǎng)絡 閱讀:225 作者:徐徐徐徐卓 欄目:數(shù)據(jù)庫

*********************8.Mysql**********************

##1.基本配置##

安裝

yum install mariadb -y

linux 筆記3-8 mysql 

關閉接口

Mariadb使用的端口默認情況下是開放的,這樣對數(shù)據(jù)庫來說必定是不安全的,所以我們需要關閉端口

linux 筆記3-8 mysql 

 

編輯/etc/my.cnf文件,在[mysqld]中加入以下參數(shù):skip-networking=1

linux 筆記3-8 mysql 

linux 筆記3-8 mysql 

linux 筆記3-8 mysql 

linux 筆記3-8 mysql 

 

安全性配置

mysql_secure_installation //輸入新密碼后一路回車即可

linux 筆記3-8 mysql 

##2.基本操作##

登陸

mysql -u root -p

linux 筆記3-8 mysql 

##查詢##

顯示數(shù)據(jù)庫SHOW DATABASES;

linux 筆記3-8 mysql 

進入數(shù)據(jù)庫USE database_name;

linux 筆記3-8 mysql 

顯示數(shù)據(jù)庫中的表SHOW TABLES;

linux 筆記3-8 mysql 

查看數(shù)據(jù)結構DESC table_name;

linux 筆記3-8 mysql 

查詢信息SELECT * FROM table_name;

linux 筆記3-8 mysql 

##添加##

添加庫CREATE DATABASE database_name;

linux 筆記3-8 mysql 

添加表CREATE TABLE table_name(...); //not null 表示不能能為空

linux 筆記3-8 mysql 

添加屬性ALTER TABLE table_name ADD .. AFTER ..

linux 筆記3-8 mysql 

添加元組INSERT INTO table_name VALUES('..','..',...)

linux 筆記3-8 mysql 

##修改##

修改屬性UPDATE users SET class=‘2’ WHERE name=‘haha’linux 筆記3-8 mysql

##刪除##

刪除元組DELETE FROM table_name WHERE ...

刪除屬性ALTER TABLE table_name DROP ..

linux 筆記3-8 mysql 

刪除表BROP TABLE table_name

linux 筆記3-8 mysql 

 

刪除庫DROP DATABASE database_name

linux 筆記3-8 mysql 

##3.用戶和訪問權限##

創(chuàng)建用戶

CREATE USER xx@localhost identified by 'hello';  //創(chuàng)建本地用戶

linux 筆記3-8 mysql 

CREATE USER zz@'%' identified by 'hello';  //創(chuàng)建所有地方可登陸的用戶

linux 筆記3-8 mysql 

 

用戶授權GRANT INSERT,SELECT on *.* to xx@localhost;

//給xx@localhost本地用戶添加插入和選擇權限給所有庫的所有表

linux 筆記3-8 mysql 

重載授權表FLUSH PRIVILEGES;

查看用戶授權SHOW GRANTS FOR xx@localhost;

linux 筆記3-8 mysql 

撤銷用戶權限REVOKE SELECT on *.* from xx@localhost;

linux 筆記3-8 mysql 

刪除用戶DROP USER xx@localhost;

linux 筆記3-8 mysql 

##4.密碼管理##

遺忘密碼

systemctl stop mariadb//停止mariadb服務

linux 筆記3-8 mysql 

mysqld_safe --skip-grant-tables & //進入安全模式

linux 筆記3-8 mysql 

mysql -u root//登錄系統(tǒng)

linux 筆記3-8 mysql 

 

UPDATE mysql.user SET Password=password('*****') WHERE User=root;

//設置新密碼

linux 筆記3-8 mysql 

fg //把打入后臺的進程調(diào)入前臺

killall -9 mysqld_safe //結束進程

linux 筆記3-8 mysql 

 

ps aux | grep mysql //查看關于mysql的進程

killall -9 3133 //結束進程

linux 筆記3-8 mysql 

 

修改密碼

mysqladmin -uroot -poldps password newps

linux 筆記3-8 mysql 

##5.備份與恢復 ##

mysqldump -uroot -pwestost linux > linux.sql //備份linux庫

linux 筆記3-8 mysql 

mysql -uroot -pwestos linux < linux.sql //恢復linux庫

linux 筆記3-8 mysql 

 

##6.圖形化管理##

1.安裝配置httpd

2.安裝配置myadmin

從網(wǎng)下下載phpadmin安裝包,放入http的默認發(fā)布目錄/var/www/html下,

并解壓文件

linux 筆記3-8 mysql 

將文件包放入一個目錄內(nèi)方便訪問

linux 筆記3-8 mysql  

按照安裝要求修改配置文件

linux 筆記3-8 mysqllinux 筆記3-8 mysql 

 

3.安裝配置php 

 linux 筆記3-8 mysql

4.安裝插件php-mysql

linux 筆記3-8 mysql 

 

5.將http加入到防火墻允許隊列中,并重啟防火墻

linux 筆記3-8 mysql 

4.重啟網(wǎng)絡服務

linux 筆記3-8 mysql 

 

5.現(xiàn)在就可以用圖形化的方式去管理數(shù)據(jù)庫了

在瀏覽器中訪問:

linux 筆記3-8 mysql 


向AI問一下細節(jié)

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

AI