Centos 安装 MySql
生活随笔
收集整理的這篇文章主要介紹了
Centos 安装 MySql
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
參考資料
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
下載 rpm
https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm將 rpm 上傳到服務器
[root@localhost bin]# cd /home/download [root@localhost download]# ll 總用量 210228 -rw-r--r--. 1 root root 194990602 5月 6 15:32 jdk-8u211-linux-x64.tar.gz -rw-r--r--. 1 root root 26024 5月 6 16:07 mysql80-community-release-el7-3.noarch.rpm -rw-r--r--. 1 root root 1014040 11月 6 23:26 nginx-1.14.1.tar.gz -rw-r--r--. 1 root root 19231911 5月 17 2018 zookeeper-3.5.4-beta.tar.gz執行 rpm 命令
[root@localhost download]# rpm -Uvh mysql80-community-release-el7-3.noarch.rpm 警告:mysql80-community-release-el7-3.noarch.rpm: 頭V3 DSA/SHA1 Signature, 密鑰 ID 5072e1f5: NOKEY 準備中... ################################# [100%] 正在升級/安裝...1:mysql80-community-release-el7-3 ################################# [100%]查看包
[root@localhost download]# yum repolist all | grep mysql mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community 禁用 mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - So 禁用 mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community 禁用 mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - So 禁用 mysql-cluster-8.0-community/x86_64 MySQL Cluster 8.0 Community 禁用 mysql-cluster-8.0-community-source MySQL Cluster 8.0 Community - So 禁用 mysql-connectors-community/x86_64 MySQL Connectors Community 啟用: 108 mysql-connectors-community-source MySQL Connectors Community - Sou 禁用 mysql-tools-community/x86_64 MySQL Tools Community 啟用: 89 mysql-tools-community-source MySQL Tools Community - Source 禁用 mysql-tools-preview/x86_64 MySQL Tools Preview 禁用 mysql-tools-preview-source MySQL Tools Preview - Source 禁用 mysql55-community/x86_64 MySQL 5.5 Community Server 禁用 mysql55-community-source MySQL 5.5 Community Server - Sou 禁用 mysql56-community/x86_64 MySQL 5.6 Community Server 禁用 mysql56-community-source MySQL 5.6 Community Server - Sou 禁用 mysql57-community/x86_64 MySQL 5.7 Community Server 禁用 mysql57-community-source MySQL 5.7 Community Server - Sou 禁用 mysql80-community/x86_64 MySQL 8.0 Community Server 啟用: 99 mysql80-community-source MySQL 8.0 Community Server - Sou 禁用啟用 57 。禁用 80
[root@localhost download]# sudo yum-config-manager --disable mysql80-community[root@localhost download]# sudo yum-config-manager --enable mysql57-community [root@localhost download]# yum repolist enabled | grep mysql mysql-connectors-community/x86_64 MySQL Connectors Community 108 mysql-tools-community/x86_64 MySQL Tools Community 89 mysql57-community/x86_64 MySQL 5.7 Community Server 347安裝
yum install mysql-community-server依賴關系解決=================================================================================================================================================================================================================================================Package 架構 版本 源 大小 ================================================================================================================================================================================================================================================= 正在安裝:mysql-community-libs x86_64 5.7.26-1.el7 mysql57-community 2.2 M替換 mariadb-libs.x86_64 1:5.5.56-2.el7mysql-community-libs-compat x86_64 5.7.26-1.el7 mysql57-community 2.0 M替換 mariadb-libs.x86_64 1:5.5.56-2.el7mysql-community-server x86_64 5.7.26-1.el7 mysql57-community 166 M 為依賴而安裝:mysql-community-client x86_64 5.7.26-1.el7 mysql57-community 24 Mmysql-community-common x86_64 5.7.26-1.el7 mysql57-community 274 k 為依賴而更新:postfix x86_64 2:2.10.1-7.el7 base 2.4 M事務概要 ================================================================================================================================================================================================================================================= 安裝 3 軟件包 (+2 依賴軟件包) 升級 ( 1 依賴軟件包)總下載量:197 M Is this ok [y/d/N]: y Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. 警告:/var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.26-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 密鑰 ID 5072e1f5: NOKEY ] 171 kB/s | 1.0 MB 00:19:29 ETA mysql-community-common-5.7.26-1.el7.x86_64.rpm 的公鑰尚未安裝 (1/6): mysql-community-common-5.7.26-1.el7.x86_64.rpm | 274 kB 00:00:06 (2/6): mysql-community-libs-5.7.26-1.el7.x86_64.rpm | 2.2 MB 00:00:05 (3/6): mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm | 2.0 MB 00:00:13 (4/6): postfix-2.10.1-7.el7.x86_64.rpm啟動 mysql
[root@localhost home]# service mysqld start Redirecting to /bin/systemctl start mysqld.service[root@localhost home]# service mysqld status Redirecting to /bin/systemctl status mysqld.service ● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: active (running) since 一 2019-05-06 16:41:58 CST; 23s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlProcess: 2818 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)Process: 2744 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)Main PID: 2821 (mysqld)CGroup: /system.slice/mysqld.service└─2821 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid5月 06 16:41:48 localhost.localdomain systemd[1]: Starting MySQL Server... 5月 06 16:41:58 localhost.localdomain systemd[1]: Started MySQL Server.修改密碼
[root@localhost home]# grep 'temporary password' /var/log/mysqld.log 2019-05-06T08:41:48.727949Z 1 [Note] A temporary password is generated for root@localhost: r#qtUrwlo22E [root@localhost home]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.26Copyright (c) 2000, 2019, 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> ALTER USER 'root'@'localhost' IDENTIFIED BY '123123'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements設置密碼策略,重新修改密碼
mysql> SHOW VARIABLES LIKE 'validate_password%'-> ; +--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password_check_user_name | OFF | | validate_password_dictionary_file | | | validate_password_length | 8 | | validate_password_mixed_case_count | 1 | | validate_password_number_count | 1 | | validate_password_policy | MEDIUM | | validate_password_special_char_count | 1 | +--------------------------------------+--------+ 7 rows in set (0.01 sec)mysql> set global validate_password_length=6-> ; Query OK, 0 rows affected (0.00 sec)mysql> SHOW VARIABLES LIKE 'validate_password%'-> ; +--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password_check_user_name | OFF | | validate_password_dictionary_file | | | validate_password_length | 6 | | validate_password_mixed_case_count | 1 | | validate_password_number_count | 1 | | validate_password_policy | MEDIUM | | validate_password_special_char_count | 1 | +--------------------------------------+--------+ 7 rows in set (0.00 sec)mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123123'; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements mysql> set global validate_password_policy=LOW; Query OK, 0 rows affected (0.00 sec)mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123123'; Query OK, 0 rows affected (0.00 sec)開放 3306 端口
[root@localhost home]# firewall-cmd --zone=public --add-port=3306/tcp --permanent success [root@localhost home]# firewall-cmd --reload success使用客戶端連接
解決客戶端連接錯誤
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123123' WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.00 sec)客戶端正常連接,安裝成功
轉載于:https://www.cnblogs.com/panzi/p/10820346.html
總結
以上是生活随笔為你收集整理的Centos 安装 MySql的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hexo搭建个人网站
- 下一篇: LeetCode 213. 打家劫舍 I