1.配置源
# wget http://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm# rpm -Uvh mysql57-community-release-el7-9.noarch.rpm #安装源,下载的那个rpm警告:mysql57-community-release-el7-9.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY准备中... ################################# [100%]正在升级/安装... 1:mysql57-community-release-el7-9 ################################# [100%]# ls /etc/yum.re* | grep mysql #查看安装的源mysql-community.repomysql-community-source.repo[root@localhost yum.repos.d]# yum repolist all | grep mysql #查看mysql的源mysql-connectors-community/x86_64 MySQL Connectors Community 启用: 21mysql-connectors-community-source MySQL Connectors Community - Sourc 禁用mysql-tools-community/x86_64 MySQL Tools Community 启用: 36mysql-tools-community-source MySQL Tools Community - Source 禁用mysql-tools-preview/x86_64 MySQL Tools Preview 禁用mysql-tools-preview-source MySQL Tools Preview - Source 禁用mysql55-community/x86_64 MySQL 5.5 Community Server 禁用mysql55-community-source MySQL 5.5 Community Server - Sourc 禁用mysql56-community/x86_64 MySQL 5.6 Community Server 禁用mysql56-community-source MySQL 5.6 Community Server - Sourc 禁用mysql57-community/x86_64 MySQL 5.7 Community Server 启用: 128mysql57-community-source MySQL 5.7 Community Server - Sourc 禁用mysql80-community/x86_64 MySQL 8.0 Community Server 禁用mysql80-community-source MySQL 8.0 Community Server - Sourc 禁用
2.安装
# yum install -y mysql-community-server #执行完就坐等好了,是不是很简单呢
3.启动mysql
# systemctl start mysqld[root@localhost yum.repos.d]# systemctl status mysqld● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since 二 2016-10-04 22:55:33 CST; 5s ago
4.修改密码
# grep 'temporary password' /var/log/mysqld.log #查看初始密码2016-10-04T14:55:29.376951Z 1 [Note] A temporary password is generated for root@localhost: hIkatKeYQ8*9# mysql -uroot -p #输入初始密码mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; #修改密码Query OK, 0 rows affected (0.02 sec)
5.开放远程连接权限
mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> select host,user from user;+-----------+-----------+| host | user |+-----------+-----------+| localhost | mysql.sys || localhost | root |+-----------+-----------+2 rows in set (0.01 sec)mysql> Grant all privileges on *.* to 'root'@'%' identified by 'MyNewPass4!' with grant option;Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> select host,user from user;+-----------+-----------+| host | user |+-----------+-----------+| % | root || localhost | mysql.sys || localhost | root |+-----------+-----------+3 rows in set (0.00 sec)
使用Sequel Pro测试连接mysql,下载地址
注:如果想修改默认配置,如db文件目录,请修改文件/etc/my.cnf