1,獲取安裝包
wget http://repo.mysql.com/mysql57-community-release-el7.rpm
或者去官網下載
2,安裝
rpm -ivh mysql57-community-release-el7.rpm
3,如果systemctl start mysqld正常啓動
#查看初始密碼
grep ‘password’ /var/log/mysqld.log |head -n1
#進入mysql,改密並導入數據
mysql -u root -p #輸入初始密碼登錄
#設置密碼
set password for root@localhost = password(‘Mysql.123’); #或者
update user set authentication_string=password(‘123456’) where user=‘Mysql.123’;
flush privileges; #刷新權限
#如果密碼過於簡單,報異常,可修改全局參數
set global validate_password_policy=0;
set global validate_password_length=1;
#數據導入
CREATE DATABASE test
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
use test;
根目錄下Source,加載sql文件
source /opt/elk/xxx.sql
#允許遠程連接
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘Mysql.123’ WITH GRANT OPTION;
flush privileges;
4,如果systemctl start mysqld無法啓動
yum install -y mariadb-server
再次啓動systemctl start mysqld
mysql -u root -p 忽略密碼,直接進入
創建用戶名密碼
use mysql;
update user set authentication_string=password(‘mysql.8888’) where user=‘root’;