MySQL 5.7.28 原始碼安裝
MySQL 5.7.28 原始碼安裝
一、介紹:
除了Oracle商業版資料庫以外, MySQL是一款原始碼開放的市面上使用率最高高的RDBMS資料庫軟體,採用的是GPL開源協議,自己是可以修改MySQL原始碼用來開發自己的系統。同樣也是透過最常用的SQL語句進行管理
MySQL 安裝方式通常分為以下三種:
l 線上Yum安裝
l 離線rpm安裝
l 原始碼編譯安裝
二、安裝前環境清理:
前面兩種安裝方式都非常簡單,但是所有安裝方式都共同需要遵頊以下安裝前的步驟:
1) 檢查是否有正在執行的MySQL程式
[root@open_source ~]# ps -ef|grep mysql |grep -v grep
2) 檢查是否有正在執行的MySQL服務
6.x之前
[root@open_source ~]# chkconfig --list |grep mysql
7.x之後
[root@open_source ~]# ls -rtl /etc/init.d/mysqld [root@open_source ~]# systemctl status mysql
3) 檢查和刪除是否有系統自帶的Mysql或mariadb
[root@open_source ~]# rpm -qa mysql [root@open_source ~]# rpm -qa mariadb
三、MySQL軟體下載:
四、開始安裝
4.1 環境準備
l 安裝libaio-devel依賴包
[root@open_source ~]# yum install -y libaio-devel
4.2 建立使用者及目錄
l 建立使用者
[root@open_source ~]# useradd -g mysql mysql
l 建立目錄
[root@open_source ~]# mkdir /mysql/3306/data
l 賦權
[root@open_source ~]# chown -R mysql.mysql /mysql
4.3 開始安裝
l 解壓軟體
[root@open_source ~]# cd /usr/local/ [root@open_source local]# tar zxf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
l 建立一個軟連線並賦權
[root@open_source local]# ln -s mysql-5.7.28-linux-glibc2.12-x86_64 mysql [root@open_source local]# chown -R mysql.mysql mysql/
l 配置環境變數
[root@open_source local]# echo "export PATH=/usr/local/mysql/bin:$PATH" /etc/profile [root@open_source local]# source /etc/profile
l 初始化資料庫
[root@open_source local]# mysqld -initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/3306/data/
l 配置My.cnf 檔案
cat > /etc/my.cnf <<EOF [mysqld] user=mysql basedir=/usr/local/mysql datadir=/mysql/3306/data log_bin=/mysql/3306/binlog/mysql-bin server_id=7 port=3306 explicit_defaults_for_timestamp=true socket=/tmp/mysql.sock [mysql] socket=/tmp/mysql.sock EOF
l 準備啟動指令碼
[root@open_source ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
l 啟動資料庫
[root@open_source ~]# /etc/init.d/mysqld start
l 登入資料庫
[root@open_source ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 Server version: 5.7.28-log MySQL Community Server (GPL) Copyright (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>
l MySQL加固:
[root@open_source ~]# /usr/local/mysql/bin/mysql_secure_installation Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 Please set the password for root here. New password: Re-enter new password: Estimated strength of the password: 50 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y Success. All done!
l 加固後無法直接登入
[root@open_source ~]# mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
l 檢視MySQL狀態
mysql> mysql> show master status; +------------------+----------+--------------+------------------+-------------------------------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------------------------------+ | mysql-bin.000009 | 3672 | | | ce8fc1bb-5fd6-11ea-869d-000c29eed638:1-20 | +------------------+----------+--------------+------------------+-------------------------------------------+ 1 row in set (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | bindb | | gtdb | | mdp | | mysql | | performance_schema | | sys | | woo | +--------------------+ 8 rows in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20674423/viewspace-2679280/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- win10 mysql-5.7.28x64位安裝Win10MySql
- 連網安裝mysql與原始碼安裝mysqlMySql原始碼
- Mysql for Linux安裝配置之—— 原始碼安裝MySqlLinux原始碼
- mysql5.5.20原始碼安裝MySql原始碼
- centos7 編譯安裝mysql 5.7.28圖文詳細教程CentOS編譯MySql
- 【轉】MySQL原始碼編譯安裝MySql原始碼編譯
- MySQL5.7.16原始碼編譯安裝MySql原始碼編譯
- 阿里雲mysql原始碼編譯安裝阿里MySql原始碼編譯
- Linux使用原始碼來安裝MySQL 5.7Linux原始碼MySql
- mysql之tar.gz原始碼安裝MySql原始碼
- mysql8.0原始碼一鍵安裝指令碼MySql原始碼指令碼
- MYSQL5.7.22 原始碼安裝 主從搭建MySql原始碼
- CentOS7.X原始碼安裝MySQL-5.7.18CentOS原始碼MySql
- Mysql5.6 for Centos6.5原始碼編譯安裝MySqlCentOS原始碼編譯
- mysql 原始碼安裝-5.7-17-19版本MySql原始碼
- 原始碼安裝openresty原始碼REST
- nginx原始碼安裝Nginx原始碼
- 原始碼安裝postgresql原始碼SQL
- Nginx 原始碼安裝Nginx原始碼
- 原始碼安裝GO原始碼Go
- PostgreSQL 10.12 安裝系列 - 原始碼安裝SQL原始碼
- 【推薦 - 原始碼安裝】nginx - 安裝原始碼Nginx
- Ubuntu 16.04下 Mysql5.7.17原始碼編譯與安裝UbuntuMySql原始碼編譯
- MYSQL5.6.40原始碼安裝 主從搭建 主主搭建MySql原始碼
- GDB 除錯 Mysql 實戰(一)原始碼編譯安裝除錯MySql原始碼編譯
- 基於Linux的MySQL5.7原始碼編譯安裝LinuxMySql原始碼編譯
- MYSQL5.7.22 原始碼安裝 主從搭建 + KEEPALIVED高可用MySql原始碼
- yum安裝與原始碼安裝比較原始碼
- linux安裝python3(原始碼安裝)LinuxPython原始碼
- paramiko 2.4.1原始碼安裝原始碼
- macbook 原始碼安裝 redisMac原始碼Redis
- macbook 原始碼安裝 nginxMac原始碼Nginx
- docker原始碼安裝NginxDocker原始碼Nginx
- 【PG安裝】postgresql10 for linux 原始碼安裝SQLLinux原始碼
- mysql高可用架構MHA搭建(centos7+mysql5.7.28)MySql架構CentOS
- EOS原始碼分析(1)安裝原始碼
- PostgreSQL-原始碼安裝(一)SQL原始碼
- 原始碼編譯安裝Redis原始碼編譯Redis