YUM安裝mysql

1.獲取rpm包

安裝前,首先要關(guān)閉防火墻和selinux
mysql官方網(wǎng)站為www.mysql.com

wget https://dev.mysql.com/get/mysql80-community-releaseel7-3.noarch.rpm

wget 官網(wǎng)得到的地址 或者下載到本地然后上傳到服務(wù)器

2.安裝mysql的yum倉庫

[root@mysql ~]# rpm -ivh  進行解壓
[root@mysql ~]# yum -y install yum-utils          安裝yum工具包

3.配置yum源

[root@mysql ~]# vim /etc/yum.repos.d/mysql-community.repo          
#Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

#Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

#Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-connectors-community]
name=MySQL Connectors Community
"/etc/yum.repos.d/mysql-community.repo" 72L, 2076C

根據(jù)mysql版本開啟,我的是5.7所以開了5.7,1表示開啟。0表示關(guān)閉

4.安裝數(shù)據(jù)庫

[root@mysql ~]# yum install -y mysql-community-server
[root@mysql ~]# systemctl start mysqld                                   啟動服務(wù)
[root@mysql ~]# systemctl enable mysqld                                 設(shè)置開機啟動

5.查找密碼

密碼保存在日志文件中
[root@mysql ~]# grep password /var/log/mysqld.log
2019-08-18T14:03:51.991454Z 1 [Note] A temporary password is generated for root@localhost: woHtkMgau9,w
冒號后的都是密碼

6.修改密碼(兩種方式)

第一種
[root@mysql ~]# mysql -uroot -p'woHtkMgau9,w' 
mysql> alter user 'root'@'localhost' identified by 'ChenChao@123';

第二種
[root@mysql ~]# mysqladmin -uroot -p'ChenChao@123' password 'ChenChao!123'
mysqladmin: [Warning] Using a password on the command line interface can be
insecure.
Warning: Since password will be sent to server in plain text, use ssl connection
to ensure password safety.
——————————————————————————————————

啟動 mysqld 服務(wù)

[root@mysql ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
查看服務(wù)狀態(tài)

[root@mysql ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
停止 mysqld 服務(wù)

[root@mysql ~]# service mysqld stop
Redirecting to /bin/systemctl stop mysqld.service
查看服務(wù)的監(jiān)聽端口


[root@mysql ~]# ss -ntal
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port
LISTEN      0      128     *:22                  *:*
LISTEN      0      128    :::22                 :::*
LISTEN      0      80     :::3306               :::*
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容