欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

MySQL數(shù)據(jù)庫(kù)安裝及配置相關(guān)

一)Centos下安裝MySQL數(shù)據(jù)庫(kù)

為下花園等地區(qū)用戶(hù)提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及下花園網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站制作、下花園網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶(hù)提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶(hù)的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

安裝MySql參考網(wǎng)址:https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/?

因?yàn)镸ySQL官網(wǎng)有創(chuàng)建yum倉(cāng)庫(kù),所以直接以yum方式安裝會(huì)非常便捷,具體步驟如下:

  1. 配置服務(wù)器的yum倉(cāng)庫(kù):將MySQL的yum倉(cāng)庫(kù)添加至服務(wù)器

????????a. 到?http://dev.mysql.com/downloads/repo/yum/地址下載

????????b. 根據(jù)服務(wù)器系統(tǒng)及版本選擇相應(yīng)的RPM包

????????c. 通過(guò)以下示例命令安裝RPM包以完成服務(wù)器yum倉(cāng)庫(kù)的擴(kuò)展

????????????rpm-Uvh mysql57-community-release-el6-n.noarch.rpm

?2. 選擇要安裝的MySQL版本

????如果是安裝最新的版本則不需任何設(shè)置,如果是安裝歷史版本,則通過(guò)以下命令設(shè)置:

????a. yum repolist all | grep mysql????????//查看所有可用版本

????b. yum-config-manager--disable mysql57-community????????//disable掉5.7版本

????c. yum-config-manager--enable mysql56-community ????????//enable 5.6版本

?3. 安裝MySQL

????yum install mysql-community-server????????//運(yùn)行該命令直接安裝第2步enable的版本

? 4. 啟動(dòng)MySQL服務(wù)

?????service mysqld start ?????//centos 6

?? ??systemctl start mysqld.service ?????//centos 7

?? ??service mysqld status????//查看啟動(dòng)情況

? 5. 登錄MySQL數(shù)據(jù)庫(kù)

? ? ?mysql -h localhost -u root -p????????//剛安裝的MySQL數(shù)據(jù)庫(kù)的root用戶(hù)無(wú)密碼,直接回車(chē)即可登錄命令行模式

特別提醒:

如果是在Centos 7及以上版本中安裝,則這里是不能成功登錄的。

需要如下一些處理步驟:

centos 7及以上版本中安裝MySQL后,root用戶(hù)每次嘗試登錄都會(huì)生產(chǎn)一個(gè)隨機(jī)密碼存在var/log/mysqld.log文件中,因此可運(yùn)行grep "password" /var/log/mysqld.log?命令獲取到該隨機(jī)密碼:

????MySQL數(shù)據(jù)庫(kù)安裝及配置相關(guān)

然后,再運(yùn)行mysql -h localhost -u root -p命令并以隨機(jī)密碼登錄命令模式,接下來(lái)再進(jìn)行第二部分的用戶(hù)及權(quán)限管理操作。

詳細(xì)信息,請(qǐng)參考以下網(wǎng)址:https://blog.csdn.net/z13615480737/article/details/78906598?

二)MySQL用戶(hù)及權(quán)限管理

用戶(hù)管理參考網(wǎng)址:?https://www.cnblogs.com/fslnet/p/3143344.html


1. 初次使用為root用戶(hù)設(shè)置密碼,運(yùn)行以下命令:

????mysql> set password for 'root'@'localhost' =password('123456') ;? ? ? ?//將密碼設(shè)置為 123456

2. 用戶(hù)管理

????mysql>use mysql;

????查看

????mysql> select host,user,password from?user?;

????創(chuàng)建

????mysql> create user ?zx_root ??IDENTIFIED?by 'xxxxx'; ? //identified by 會(huì)將純文本密碼加密作為散列值存儲(chǔ)

????修改

????mysql>rename ? user ?feng ?to ? newuser;//mysql 5之后可以使用,之前需要使用update 更新user表

????刪除

????mysql>drop?user newuser; ? //mysql5之前刪除用戶(hù)時(shí)必須先使用revoke 刪除用戶(hù)權(quán)限,然后刪除用戶(hù),mysql5之后drop 命令可以刪除用戶(hù)的同時(shí)刪除用戶(hù)的相關(guān)權(quán)限

????更改密碼

????mysql> set password?for?zx_root =password('xxxxxx');

?????mysql> update ?mysql.user ?set ?password=password('xxxx') ?where user='otheruser';

3. 查看用戶(hù)權(quán)限

????mysql> show grants for zx_root;

????賦予權(quán)限

????mysql> grant?select/all?on dmc_db.* ?to?zx_root;

????回收權(quán)限

????mysql> revoke ?select on dmc_db.* ?from ?zx_root; ?//如果權(quán)限不存在會(huì)報(bào)錯(cuò)

?

????上面的命令也可使用多個(gè)權(quán)限同時(shí)賦予和回收,權(quán)限之間使用逗號(hào)分隔

????grant select on testdb.* to common_user@’%’;

????grant insert on testdb.* to common_user@’%’;

????grant update on testdb.* to common_user@’%’;

????grant delete on testdb.* to common_user@’%’;

????或者,用一條 MySQL 命令來(lái)替代:

????grant select, insert, update, delete on testdb.* to common_user@'%';

????如果想立即看到結(jié)果使用

????flush ?privileges ;

????命令更新?

?

????設(shè)置權(quán)限時(shí)必須給出以下信息

????1,要授予的權(quán)限

????2,被授予訪(fǎng)問(wèn)權(quán)限的數(shù)據(jù)庫(kù)或表

????3,用戶(hù)名

????grant和revoke可以在幾個(gè)層次上控制訪(fǎng)問(wèn)權(quán)限

????1,整個(gè)服務(wù)器,使用 grant ALL ?和revoke ?ALL

????2,整個(gè)數(shù)據(jù)庫(kù),使用on ?database.*

????3,特點(diǎn)表,使用on ?database.table

????4,特定的列

????5,特定的存儲(chǔ)過(guò)程

?

????user表中host列的值的意義

????% ? ? ? ? ? ? ?匹配所有主機(jī)

????localhost ? ?localhost不會(huì)被解析成IP地址,直接通過(guò)UNIXsocket連接

????127.0.0.1 ? ? ?會(huì)通過(guò)TCP/IP協(xié)議連接,并且只能在本機(jī)訪(fǎng)問(wèn);

????::1 ? ? ? ? ? ? ? ??::1就是兼容支持ipv6的,表示同ipv4的127.0.0.1

?

?4.權(quán)限授予實(shí)例

????grant 數(shù)據(jù)庫(kù)開(kāi)發(fā)人員,創(chuàng)建表、索引、視圖、存儲(chǔ)過(guò)程、函數(shù)。。。等權(quán)限

????grant 創(chuàng)建、修改、刪除 MySQL 數(shù)據(jù)表結(jié)構(gòu)權(quán)限。

????grant create on testdb.* to developer@’192.168.0.%’;

????grant alter on testdb.* to developer@’192.168.0.%’;

????grant drop on testdb.* to developer@’192.168.0.%’;

????grant 操作 MySQL 外鍵權(quán)限

????grant references on testdb.* to developer@’192.168.0.%’;

????grant 操作 MySQL 臨時(shí)表權(quán)限

????grant create temporary tables on testdb.* to developer@’192.168.0.%’;

????grant 操作 MySQL 索引權(quán)限

????grant index on testdb.* to developer@’192.168.0.%’;

????grant 操作 MySQL 視圖、查看視圖源代碼權(quán)限

????grant create view on testdb.* to developer@’192.168.0.%’;

????grant show view on testdb.* to developer@’192.168.0.%’;

????grant 操作 MySQL 存儲(chǔ)過(guò)程、函數(shù)權(quán)限

????grant create routine on testdb.* to developer@’192.168.0.%’; ????????//now, can show procedure status

????grant alter routine on testdb.* to developer@’192.168.0.%’; ????????//now, you can drop a procedure

????grant execute on testdb.* to developer@’192.168.0.%’;

????

????grant 普通 DBA 管理某個(gè) MySQL 數(shù)據(jù)庫(kù)的權(quán)限

????grant all privileges on testdb to dba@’localhost’;

????其中,關(guān)鍵字 “privileges” 可以省略。

????

????grant 高級(jí) DBA 管理 MySQL 中所有數(shù)據(jù)庫(kù)的權(quán)限

????grant all on *.* to dba@’localhost’;

????

????MySQL grant 權(quán)限,分別可以作用在多個(gè)層次上

????1. grant 作用在整個(gè) MySQL 服務(wù)器上:

????grant select on *.* to dba@localhost;?????????// dba 可以查詢(xún) MySQL 中所有數(shù)據(jù)庫(kù)中的表。

????grant all on *.* to dba@localhost; ????????????// dba 可以管理 MySQL 中的所有數(shù)據(jù)庫(kù)

????2. grant 作用在單個(gè)數(shù)據(jù)庫(kù)上:

????grant select on testdb.* to dba@localhost; ????????// dba 可以查詢(xún) testdb 中的表。

????3. grant 作用在單個(gè)數(shù)據(jù)表上:

????grant select, insert, update, delete on testdb.orders to dba@localhost;

????4. grant 作用在表中的列上:

????grant select(id, se, rank) on testdb.apache_log to dba@localhost;

????5. grant 作用在存儲(chǔ)過(guò)程、函數(shù)上:

????grant execute on procedure testdb.pr_add to ’dba’@’localhost’;

????grant execute on function testdb.fn_add to ’dba’@’localhost’;

注意:

????a. 修改完權(quán)限以后 一定要刷新服務(wù),或者重啟服務(wù),刷新服務(wù)用:FLUSH PRIVILEGES。

????b.?MySQL中默認(rèn)存在一個(gè)用戶(hù)名為空的賬戶(hù),只要在本地,可以不用輸入賬號(hào)密碼即可登錄到MySQL中。而因?yàn)檫@個(gè)賬戶(hù)的存在,導(dǎo)致新增的用戶(hù)無(wú)法用賬號(hào)密碼登錄,只需以root用戶(hù)登陸,然后刪掉即可。

????????

????mysql?-u?root???#?以root賬戶(hù)登錄MySQL
use?mysql???#選擇mysql庫(kù)
delete?from?user?where?User='';??#刪除賬號(hào)為空的行
flush?privileges;??#刷新權(quán)限
exit??#退出mysql

????c. 運(yùn)行下面命令使root用戶(hù)可遠(yuǎn)程登錄

????mysql>?grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

?

權(quán)限表

權(quán)限說(shuō)明
all
alter
alter routine使用alter procedure 和drop procedure
create
create routine使用create ?procedure
create temporary tables使用create temporary table
create ?user
create view
delete
drop
execute使用call和存儲(chǔ)過(guò)程
file使用select into outfile ?和load data infile
grant option可以使用grant和revoke
index可以使用create index 和drop index
insert
lock tables鎖表
process使用show full processlist
reload? ?使用flush
replication client服務(wù)器位置訪(fǎng)問(wèn)
replocation slave由復(fù)制從屬使用
select
show databases
show view
shutdown使用mysqladmin shutdown 來(lái)關(guān)閉mysql
super
update
usage無(wú)訪(fǎng)問(wèn)權(quán)限

三)創(chuàng)建遠(yuǎn)程登錄

1. 首先,授權(quán)特定用戶(hù)具有遠(yuǎn)程登錄權(quán)限,具體方法,參考上述第二部分。

2. 其次,MySQL數(shù)據(jù)庫(kù)默認(rèn)使用3306端口,需要對(duì)外開(kāi)放3306端口,用戶(hù)才能從遠(yuǎn)程端登錄數(shù)據(jù)庫(kù)系統(tǒng)。

a. centos 7以下執(zhí)行以下命令對(duì)外開(kāi)放3306端口:

#/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

#/etc/rc.d/init.d/iptables save

#/etc/init.d/iptables status

b. centos 7及以上執(zhí)行以下命令對(duì)外開(kāi)放3306端口:

#firewall-cmd --zone=public --add-port=3306/tcp --permanent
#firewall-cmd --reload?

四)數(shù)據(jù)庫(kù)備份及恢復(fù)

備份

  1. 備份數(shù)據(jù)庫(kù)命令,兩命令沒(méi)有區(qū)別

????????mysqldump -hhostname -uusername -p databasename > backupfile.sql

????????mysqldump?-hhostname -uusername -p --add-drop-table? databasename > backupfile.sql

注:這2個(gè)命令dump的數(shù)據(jù)沒(méi)有數(shù)據(jù)庫(kù)創(chuàng)建語(yǔ)句,因此在恢復(fù)時(shí),如果目標(biāo)庫(kù)不存在,需先手動(dòng)創(chuàng)建!

? ?2. 同時(shí)備份多個(gè)MySQL數(shù)據(jù)庫(kù)

????????mysqldump -hhostname -uusername -p --databases databasename1 databasename2 databasenameN > backupfile.sql

? ?3. 僅僅備份表結(jié)構(gòu)

????????mysqldump? -hhostname -uusername -p --no-data --databases database1 database2 databaseN > backupfile.sql

注:這2個(gè)命令dump的數(shù)據(jù)含數(shù)據(jù)庫(kù)創(chuàng)建語(yǔ)句!

? ?4. 只備份數(shù)據(jù)庫(kù)中某些表

????????mysqldump -hhostname -uusername -p databasename? specify_table1 specify_table2 > backupfile.sql

? ?5. 備份所有數(shù)據(jù)庫(kù)

????????mysqldump? -hhostname -uusername -p --all-databases > backupfile.sql

? ? 6. 將數(shù)據(jù)庫(kù)壓縮備份

????????mysqldump -hhostname -uusername -p databasename? | gzip > backupfile.sql.gz


恢復(fù)

? ? 1.? 恢復(fù)數(shù)據(jù)庫(kù)命令

????????mysql -hhostname -uusername -p databasename < backupfile.sql

? ? 2. 從多個(gè)數(shù)據(jù)庫(kù)備份或所有數(shù)據(jù)庫(kù)備份中恢復(fù)

????????mysql -hhostname -uusername -p --one-database databasename < backupfile.sql????????????//恢復(fù)特定的數(shù)據(jù)庫(kù),目標(biāo)庫(kù)必須存在

????????mysql -hhostname -uusername -p?< backupfile.sql??????????????//從多個(gè)備份中一次恢復(fù)全部數(shù)據(jù)庫(kù),目標(biāo)庫(kù)不存在可以自動(dòng)創(chuàng)建

? ? 3. 恢復(fù)壓縮的MySQL數(shù)據(jù)庫(kù)

????????gunzip < backupfile.sql.gz | mysql -hhostname -uusername -p databasename

注:

???恢復(fù)的邏輯是:

????1. 在備份后新建的表將保留;

? ? 2. 刪除了備份中的表,或者修改了備份中的數(shù)據(jù)都將恢復(fù)。

當(dāng)前名稱(chēng):MySQL數(shù)據(jù)庫(kù)安裝及配置相關(guān)
本文鏈接:http://www.chinadenli.net/article38/gjcjsp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航網(wǎng)站改版商城網(wǎng)站定制開(kāi)發(fā)外貿(mào)建站App設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司