您好,登錄后才能下訂單哦!
1. 添加MySQL Yum源
MySQL官網>DOWNLOADS>MySQL Yum Repository找到合適版本的yum源
$wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm $sudo rpm -Uvh mysql80-community-release-el7-2.noarch.rpm #查看MySQL數據庫各個版本信息 $yum repolist all | grep mysql
2. 選擇安裝版本
修改/etc/yum.repos.d/mysql-community.repo 文件,選擇MySQL5.7版本
# 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
3. 安裝
#執行以下命令安裝MySQL yum install mysql-community-server #啟動mysql(CentOS7中) systemctl start mysqld.service #低版本的操作系統可用以下指令 service mysqld start #查看MySQL狀態 systemctl status mysqld.service #低版本操作系統可用以下指令 service mysqld status
4. 查看并修改密碼
$grep "password" /var/log/mysqld.log 2019-04-11T08:17:16.706096Z 1 [Note] A temporary password is generated for root@localhost: ux#bkaM(k1q- $mysql -u root -p >ux#bkaM(k1q- # 修改密碼 mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'complex password'; mysql>set global validate_password_policy=0; mysql>set global validate_password_length=1; mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'simple password';
5. 配置開放3306端口
授權的方式允許任何主機訪問mysql服務器:【一般采用這個即可,限制端口訪問交由firewalld來做】
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
限定ip訪問:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'jack'@'10.10.50.127' IDENTIFIED BY 'password' WITH GRANT OPTION;
以上就是centos7 安裝mysql和mysqlclient遇到的一些坑和需要注意的知識點總結,感謝大家的閱讀和對億速云的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。