CentOS7.7系统使用yum方式实现MySQL 5.7安装
下文主要给大家带来CentOS7.7系统使用yum方式实现MySQL 5.7安装,希望这些内容能够带给大家实际用处,这也是我编辑CentOS7.7系统使用yum方式实现MySQL 5.7安装这篇文章的主要目的。好了,废话不多说,大家直接看下文吧。
1、删除CentOS 7.7内置的MariaDB相关组件:
# rpm -qa | grep -i mariadb --> mariadb-libs-5.5.64-1.el7.x86_64
# rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64
如果之前安装过MySQL,先卸载:# rpm -qa | grep -i mysql
如果存在/etc/my.cnf配置文件,先删除:# rm -rf /etc/my.cnf
2、安装mysql57-community-release-el7.rpm:
# rpm -ivh http://repo.mysql.com/mysql57-community-release-el7.rpm
备注:安装后会在/etc/yum.repos.d目录中生成mysql-community-source.repo和mysql-community.repo
3、安装MySQL:
# yum list all | grep mysql-community
# yum -y install mysql-community-client mysql-community-common mysql-community-devel mysql-community-libs mysql-community-libs-compat mysql-community-server mysql-community-test
4、初始化MySQL:# mysqld --initialize --user=mysql --datadir=/var/lib/mysql
备注:初始化之前确保/var/lib/mysql目录为空
5、修改/etc/my.cnf配置文件:
# mv /etc/my.cnf /etc/my.cnf.bak
# vim /etc/my.cnf
[mysqld]
port=3306
socket=/var/lib/mysql/mysql.sock
datadir=/var/lib/mysql
pid-file=/var/run/mysqld/mysqld.pid
log-error=/var/log/mysqld.log
lower_case_table_names=1
character_set_server=utf8mb4
collation_server=utf8mb4_general_ci
innodb_file_per_table=1
skip_name_resolve=1
slow_query_log=1
slow_query_log_file=mysql-slow.log
symbolic-links=0
explicit_defaults_for_timestamp=1
server_id=1
sync_binlog=1
innodb_flush_log_at_trx_commit=1
log_bin=mysql-bin
log_bin_index=mysql-bin.index
binlog_format=row
6、启动MySQL服务:
# systemctl start mysqld.service
# systemctl status mysqld.service
# ps aux | grep mysqld
# ss -tunlp | grep 3306
# tail -100 /var/log/mysqld.log
7、配置MySQL服务开机自启:# systemctl enable mysqld.service
8、查看root@localhost用户的初始密码:# grep password /var/log/mysqld.log
9、配置MySQL安全向导:# mysql_secure_installation
10、授权root用户远程登录:
# mysql -uroot -p
mysql> create user root@'192.168.0.%' identified by '123456';
mysql> grant all on *.* to root@'192.168.0.%';
mysql> flush privileges;
11、使用Navicat Premium连接MySQL:
对于以上关于CentOS7.7系统使用yum方式实现MySQL 5.7安装,大家是不是觉得非常有帮助。如果需要了解更多内容,请继续关注我们的行业资讯,相信你会喜欢上这些内容的。