根據系統下載yum源mysql
https://dev.mysql.com/downloads/repo/yum/sql
rpm -ivh xxxxx.rpmshell
vim /etc/yum.repos.d/mysql-community.repo數據庫
enable想要下載的版本vim
yum install mysql-community-serverthis
配置裏修改瞭如下datadir路徑spa
vim /etc/my.cnfserver
啓動服務blog
service mysqld startit
查看root初始密碼
grep 'temporary password' /var/log/mysqld.log
登陸數據庫
shell> mysql -uroot -p
此時使用會報錯「You must reset your password using ALTER USER statement before executing this statement.」
使用如下步驟設置新密碼:
step 1: SET PASSWORD = PASSWORD('your new password');
step 2: ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
step 3: flush privileges;
設置完成後從新登陸數據庫