centos 7 安装mysql 5.7

centos 7 安装mysql

1. 下载https://dev.mysql.com/downloads/mysql 下载 rpm-bundle.rar 解压并上传到linux服务器上

2. 编辑/etc/sudoers, 将当前用户添加到sudoer列表中

3. 关闭selinux和firewall
sestatus

如果要临时关闭,可以执行
setenforce 0

如果要永久关闭,可以修改配置文件/etc/selinux/config,将SELINU置为disabled。
[root@rdo ~]# sudo vi /etc/selinux/config

修改该配置文件也可以执行下面的命令来完成

sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
修改完成后,保存重启,重启后状态如下:

[root@rdo ~]# sestatus
SELinux status: disabled


关闭防火墙
临时关闭防火墙
systemctl stop firewalld
永久防火墙开机自启动
systemctl disable firewalld
临时打开防火墙
systemctl start firewalld
防火墙开机启动
systemctl enable firewalld
查看防火墙状态
systemctl status firewalld

4. 卸载mariadb

[root@localhost mysql-5.7.19-1.el7.x86_64.rpm-bundle]# rpm -qa | grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@localhost mysql-5.7.19-1.el7.x86_64.rpm-bundle]# rpm -e --nodeps mariadb-libs
[root@localhost mysql-5.7.19-1.el7.x86_64.rpm-bundle]# rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm

4. 安装perl和mysql
sudo yum install perl

rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm

4. 配置并启动mysql

开机启动
systemctl enable mysqld.service
启动
service mysqld start
重启
service mysqld restart

获取临时密码
[root@localhost mysql-5.7.19-1.el7.x86_64.rpm-bundle]# sudo grep 'temporary password' /var/log/mysqld.log
2017-10-10T08:56:31.185129Z 1 [Note] A temporary password is generated for root@localhost: aSur<sc1*wd_
[root@localhost mysql-5.7.19-1.el7.x86_64.rpm-bundle]# mysql -u root -p
Enter password:

修改密码
mysql> set password for 'root'@'localhost' = password('Password1234*');

use mysql;
取消IP地址限制
update user set host='%' where user='root';
grant all privileges on *.* to 'root'@'%' identified by "Password1234*" with grant option;
FLUSH PRIVILEGES;


大小写敏感
windows下 安装目录的my.ini,在[mysqld]节下添加lower_case_table_names=0 默认为1(不敏感)
linux下 编辑/etc/my.cnf,在[mysqld]节下添加lower_case_table_names=1 默认为0(敏感)
重启mysql

 

posted @ 2017-10-12 11:52  Harry Jiang  阅读(230)  评论(0编辑  收藏  举报