环境及版本
centos ===> CentOS Linux release 7.4.1708 64位
mysql ===> 5.7.23 64位 (mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar)
1. 建立soft目录,然后把软件包上传上来
2. 解压缩
# tar –xvf mysql-5.7.23-1.el7.x86_64.rpm-bundle.tar
3. 卸载centos自带的mariadb-lib(不卸载安装会报错)
[root@VM_0_16_centos mysql5.7.23]# rpm -e –-nodeps mariadb-libs-5.5.56-2.el7.x86_64
如果上面的命令卸载出错,请用以下方法
# yum remove mysql-libs
4. 按顺序安装如下四个软件包
# rpm -ivh mysql-community-common-5.7.23-1.el7.x86_64.rpm
# rpm -ivh mysql-community-libs-5.7.23-1.el7.x86_64.rpm
# rpm -ivh mysql-community-client-5.7.23-1.el7.x86_64.rpm
# rpm -ivh mysql-community-server-5.7.23-1.el7.x86_64.rpm
5. 安装过程中可能出现的问题及解决方案
1).缺少libaio
# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.17-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
libaio.so.1()(64bit) 被 mysql-community-server-5.7.17-1.el7.x86_64 需要
libaio.so.1(LIBAIO_0.1)(64bit) 被 mysql-community-server-5.7.17-1.el7.x86_64 需要
libaio.so.1(LIBAIO_0.4)(64bit) 被 mysql-community-server-5.7.17-1.el7.x86_64 需要
net-tools 被 mysql-community-server-5.7.17-1.el7.x86_64 需要
解决办法:
# yum install libaio
2)缺少net-tools
# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.17-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
错误:依赖检测失败:
net-tools 被 mysql-community-server-5.7.17-1.el7.x86_64 需要
解决办法:
#yum install net-tools
3)缺少numactl
# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
报错:warning: mysql-community-server-5.7.9-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.9-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-5.7.9-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-5.7.9-1.el6.x86_64
解决办法:
#yum install numactl
6. 初始化数据库
# mysqld --initialize #初始化后会在/var/log/mysqld.log生成随机密码
请自行先记录下来
#more /var/log/mysqld.log
7. 修改mysql数据库目录的所属用户及其所属组,然后启动mysql数据库
这一步是为了安全考虑,即便别人黑了你的数据库,也无法取到系统root用户信息
# chown mysql:mysql /var/lib/mysql -R #mysql组及mysql用户已经自动被创建了
# systemctl start mysqld.service
# systemctl status mysqld.service
或者用service命令,如下
# service mysqld start
8. 登录mysql,并修改root用户的密码(系统强制要求,否则不能操作mysql)
# mysql -uroot -p
9. 修改访问权限(给所有机器授权登录此mysql)
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
10. 开放3306端口
# firewall-cmd --zone=public --add-port=3306/tcp --permanent
# systemctl restart firewalld.service
11. 修改字符集并修改配置
执行如下图所示命令查看字符集
修改配置文件(配置文件的位置: /etc/my.cnf)
lower_case_table_names=1 意思是表名不区分大小写
重启mysql服务
#service mysqld restart
重新查看字符集
ok,改过来了
12. 在windows里面用sqlyog客户端登录一下
ok 大功告成!!!