產(chǎn)品型號(hào):Thinkpad E15
系統(tǒng)版本:centos7
軟件版本:mysql 5.7
mysql安裝教程
1.使用yum安裝mysql數(shù)據(jù)庫(kù)的軟件包
[root@xuegod63 ~]# yum -y install mariadb-server mariadb
注:
mariadb-server #MariaDB數(shù)據(jù)庫(kù)
mariadb # MariaDB服務(wù)器Linux下客戶(hù)端
注:從centos7系統(tǒng)開(kāi)始,系統(tǒng)中自帶的mysql數(shù)據(jù)庫(kù)變成了mariadb-server,mariadb-server和mysql操作上一樣。mariadb-server是mysql的一個(gè)分支。
2.啟動(dòng)數(shù)據(jù)庫(kù)服務(wù)
[root@xuegod63 ~]# systemctl start mariadb #啟動(dòng)MariaDB服務(wù)
[root@xuegod63 ~]# systemctl enable mariadb #設(shè)置開(kāi)啟自動(dòng)啟動(dòng)MariaDB服務(wù)
3. 安裝完mariadb-server后,運(yùn)行mysql_secure_installation去除安全隱患
[root@xuegod63 ~]# mysql_secure_installation #進(jìn)入安全配置導(dǎo)向
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): #初次運(yùn)行直接回車(chē),因?yàn)閞oot用戶(hù)沒(méi)有密碼
OK, successfully used password, moving on…
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y #是否設(shè)置root用戶(hù)密碼,輸入Y
New password: 123456 #新密碼123456
Re-enter new password: 123456
Password updated successfully!
。。。
Remove anonymous users? [Y/n] Y #是否刪除匿名用戶(hù),生產(chǎn)環(huán)境建議刪除,所以直接回車(chē)或Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y #是否禁止root遠(yuǎn)程登錄,根據(jù)自己的需求選擇Y/n并回車(chē),建議禁止
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y #是否刪除test數(shù)據(jù)庫(kù),直接回車(chē)或Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y #是否重新加載權(quán)限表,直接回車(chē)
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
… Success!
至此數(shù)據(jù)庫(kù)安裝成功。
4. 登錄數(shù)據(jù)庫(kù)
[root@xuegod63 ~]# mysql -u root -p123456
MariaDB [(none)]> show databases; #沒(méi)有test數(shù)據(jù)庫(kù) #執(zhí)行時(shí),所有命令以;號(hào)結(jié)尾
+-------------------------+
| Database |
+-------------------------+
| information_schema |
| mysql |
| ucenter |
+-------------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> exit #退出命令可以加分號(hào),也可以不加分號(hào)。
總結(jié):
1、使用yum安裝mysql數(shù)據(jù)庫(kù)的軟件包
2、啟動(dòng)數(shù)據(jù)庫(kù)服務(wù)
3、運(yùn)行mysql_secure_installation去除安全隱患
4、登錄數(shù)據(jù)庫(kù)
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com