centos7mysql數(shù)據(jù)庫(kù)安裝和配置-創(chuàng)新互聯(lián)

一、系統(tǒng)環(huán)境

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

成都創(chuàng)新互聯(lián)長(zhǎng)期為上1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為蒼溪企業(yè)提供專業(yè)的成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站,蒼溪網(wǎng)站改版等技術(shù)服務(wù)。擁有十載豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。

二、mysql安裝

#yum install mysql mysql-server mysql-devel
安裝mysql-server失敗,如下圖:
centos7 mysql數(shù)據(jù)庫(kù)安裝和配置

[root@localhost ~]# yum install mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.sina.cn
  • extras: mirrors.sina.cn
  • updates: mirrors.sina.cn
    No package mysql-server available.
    Error: Nothing to do

這是因?yàn)镃entOS 7用mariadb代替了MySQL數(shù)據(jù)庫(kù)軟件。


有兩種解決辦法:

1、方法一:安裝mariadb
MariaDB數(shù)據(jù)庫(kù)管理系統(tǒng)是MySQL的一個(gè)分支,主要由開(kāi)源社區(qū)在維護(hù),采用GPL授權(quán)許可。開(kāi)發(fā)這個(gè)分支的原因之一是:甲骨文公司收購(gòu)了MySQL后,有將MySQL閉源的潛在風(fēng)險(xiǎn),因此社區(qū)采用分支的方式來(lái)避開(kāi)這個(gè)風(fēng)險(xiǎn)。MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能輕松成為MySQL的代替品。

安裝mariadb,大小59 M。

[root@localhost ~]# yum install mariadb-server mariadb
mariadb數(shù)據(jù)庫(kù)的相關(guān)命令是:

systemctl start mariadb #啟動(dòng)MariaDB

systemctl stop mariadb #停止MariaDB

systemctl restart mariadb #重啟MariaDB

systemctl enable mariadb #設(shè)置開(kāi)機(jī)啟動(dòng)

所以先啟動(dòng)數(shù)據(jù)庫(kù)

[root@localhost ~]# systemctl start mariadb
然后就可以正常使用mysql了

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]>

安裝mariadb后顯示的也是 MariaDB [(none)]> ,可能看起來(lái)有點(diǎn)不習(xí)慣。下面是第二種方法。

2、方法二:官網(wǎng)下載安裝mysql-server
下載mysql:
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
源碼安裝:
rpm -ivh mysql-community-release-el7-5.noarch.rpm
安裝服務(wù):
yum install mysql-community-server
安裝成功后重啟mysql服務(wù)。

service mysqld restart
初次安裝mysql,root賬戶沒(méi)有密碼。

[root@localhost ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)

mysql>

設(shè)置mysql登錄密碼:

mysql> set password for 'root'@'localhost' =password('password');
Query OK, 0 rows affected (0.00 sec)

mysql>
不需要重啟數(shù)據(jù)庫(kù)即可生效。

在mysql安裝過(guò)程中如下內(nèi)容:

Installed:
mysql-community-client.x86_64 0:5.6.26-2.el7 mysql-community-devel.x86_64 0:5.6.26-2.el7
mysql-community-libs.x86_64 0:5.6.26-2.el7 mysql-community-server.x86_64 0:5.6.26-2.el7

Dependency Installed:
mysql-community-common.x86_64 0:5.6.26-2.el7

Replaced:
mariadb.x86_64 1:5.5.41-2.el7_0 mariadb-devel.x86_64 1:5.5.41-2.el7_0 mariadb-libs.x86_64 1:5.5.41-2.el7_0
mariadb-server.x86_64 1:5.5.41-2.el7_0

所以安裝完以后mariadb自動(dòng)就被替換了,將不再生效。

[root@localhost ~]# rpm -qa |grep mariadb
[root@localhost ~]#

三、配置mysql

1、編碼
mysql配置文件為/etc/my.cnf

最后加上編碼配置

[mysql]
default-character-set =utf8
這里的字符編碼必須和/usr/share/mysql/charsets/Index.xml中一致。

2、遠(yuǎn)程連接設(shè)置
把在所有數(shù)據(jù)庫(kù)的所有表的所有權(quán)限賦值給位于所有IP地址的root用戶。

mysql> grant all privileges on . to root@'%'identified by 'password';
如果是新用戶而不是root,則要先新建用戶

mysql>create user 'username'@'%' identified by 'password';
此時(shí)就可以進(jìn)行遠(yuǎn)程連接了。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

分享題目:centos7mysql數(shù)據(jù)庫(kù)安裝和配置-創(chuàng)新互聯(lián)
當(dāng)前網(wǎng)址:http://bm7419.com/article42/ceoihc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、網(wǎng)站策劃、響應(yīng)式網(wǎng)站云服務(wù)器、手機(jī)網(wǎng)站建設(shè)企業(yè)網(wǎng)站制作

廣告

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

商城網(wǎng)站建設(shè)