1.下載及安裝
rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el6-3.noarch.rpm
yum -y install mysql-community-server
或使用 yum 下載
下載頁面
---linux 7
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
---linux 6
wget https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm
#安裝yum源
yum local install mysql80-community-release-el7-1.noarch.rpm
2.啟動mysql
------ linux 7
sudo /usr/bin/systemctl enable mysqld
systemctl start mysqld
------ linux 6
service mysqld start
3.安裝好mysql後, 找到原始的 mysql root 密碼
cat /var/log/mysqld.log | grep password
[root@ora28 ~]# cat /var/log/mysqld.log | grep password
2020-07-24T08:47:09.576906Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: G8J=LGYtBS9D
4.使用這個密碼登入且修改密碼
mysql -u root -p
alter user 'root'@'localhost' identified by 'N.:129%eYmyk%yM';
5.設定 root帳號可遠端登入
use mysql;
update user set host='%' where user='root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
FLUSH PRIVILEGES;
-------linux 7
#啟動mysql
systemctl start mysqld.service
#結束
systemctl stop mysqld.service
#重啟
systemctl restart mysqld.service
#開機自啟
systemctl enable mysqld.service
------linux 6
#啟動mysql
service mysqld start
#結束
service mysqld stop
#重啟
service mysqld reatart
#狀態
service mysqld status
#開機自啟
service mysqld enable
----配置 read only 帳號
GRANT ALL PRIVILEGES ON dbtest.* TO 'requery'@'%';
GRANT SELECT ON dbtest.* TO 'requery'@'%';
----配置 DBA 帳號
CREATE USER 'dba'@'%' IDENTIFIED BY 'Qvt4c.scBnEETeX0.12';
GRANT Alter, Alter Routine, Create, Create Routine, Create Temporary Tables, Create User, Create View, Delete, Drop, Event, Execute, File, Grant Option, Index, Insert, Lock Tables, Process, References, Reload, Replication Client, Replication Slave, Select, Show Databases, Show View, Shutdown, Super, Trigger, Update ON *.* TO `dba`@`%`;
GRANT ALL PRIVILEGES ON *.* TO 'dba'@'%';
alter user 'dba'@'%' identified by 'Qvt4c.scBnEETeX0.12';
FLUSH PRIVILEGES;
----忘記root密碼,強力登入配置密碼 ---- MySQL 8.0.11中刪除此方法
/etc/my.cnf
輸入 skip-grant-tables
mysql -u root
flush privileges;
alter user 'root'@'%' identified by 'Qvt4c.scBnEETeX0.12';
flush privileges;
/etc/my.cnf
拿掉 skip-grant-tables
----- 修改mysql資料存放的路徑
關閉mysql
systemctl stop mysqld
配置新資料夾
mkdir /mysql
mkdir /mysql/data
mkdir /mysql/data/binlogs
mkdir /mysql/log
mkdir /mysql/software
echo "" > /mysql/log/mysqld.log
chown -R mysql:mysql /mysql/
修改 /etc/my.cnf
datadir=/mysql/data
socket=/mysql/data/mysql.sock
log-error=/mysql/log/mysqld.log
log-bin=/mysql/data/binlogs/mysql-bin
將原本資料使用的移去新的資料夾
cp -rp /var/lib/mysql/* /mysql/data/
修改安全配置
setenforce 0
vi /etc/selinux/config 檔案中設定 SELINUX=disabled
啟動mysql
systemctl start mysqld
-----------移除 mysql
yum remove mysql-libs mysql-server mysql-client mysql
----------mysql 備庫開啟 read only 模式
備庫查詢
show global variables like "%read_only%";
set global read_only=1;
set global read_only=1;
ON= 開啟read only
但對於super user 是無效的, super user 是可以對資料庫讀寫
備庫執行
flush tables with read lock;
super user 就不能對資料庫讀寫, 但相對的備庫就不能從主庫同步資料過來
相對的解鎖指令
unlock tables;
--------------設定用戶密碼強度
show variables like '%password%'
-----可允許低強度
set global validate_password.policy=0;
---長度最少4
set global validate_password.length=4;
關於mysql 8.0.21 create partition DATA DIRECTORY 一些相關的新規定
回覆刪除https://mysqlserverteam.com/new-consistency-for-datafile-locations-in-mysql-8-0-21/