Mysql5.7
# cd /etc/yum.repos.d/
# 新增编辑一个yum源
# vim mysql.repo
内容:
[mysql57-community]
name=MySQL 5.7 Community Server
## baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# 安装
yum install -y mysql-community-common mysql-community-libs mysql-community-client mysql-community-server mysql-community-devel
# 启动/停止Mysql (和service mysqld start 效果一样)
# /bin/systemctl start mysqld.service
# /bin/systemctl stop mysqld.service
启动后:
# 查看首次启动的随机密码
# grep 'temporary password' /var/log/mysqld.log
#进入mysql
# mysql -uroot -pxxx
# 修改密码(5.7版本以上必须要有大小写特殊字符)
# ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678@Abc';
# 授权远程登录Mysql
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678@Abc' WITH GRANT OPTION;
Mysql8.0
mysql8.0安装有点ZZ,研究一下先
create user cc@'%' identified by '12345678@Abc';
GRANT ALL ON *.* TO 'cc'@'%' WITH GRANT OPTION;
ALTER USER 'root'@'%' IDENTIFIED BY '12345678@Abc';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '12345678@Abc' WITH GRANT OPTION;