CentOS7安装 mysql5.7
2022/2/20 19:38:09
本文主要是介绍CentOS7安装 mysql5.7,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
CentOS7安装 mysql5.7
-
下载 rpm 包
wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm rpm -ivh mysql57-community-release-el7-10.noarch.rpm rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
-
yum 安装 mysql
yum install mysql-community-server
-
启动 mysql
systemctl start mysqld
-
查找安装时的 root 密码并修改
grep "password" /var/log/mysqld.log 2022-02-19T17:14:10.438444Z 1 [Note] A temporary password is generated for root@localhost: f!XpS*:-D3NZ 2022-02-19T17:14:42.610153Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
# 输入查询到的密码 mysql -uroot -p ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
-
如需设置简单密码,需要进行如下设置
set global validate_password_policy=LOW; set global validate_password_mixed_case_count=0; set global validate_password_number_count=3; set global validate_password_special_char_count=0; set global validate_password_length=3; # 设置简单密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
-
开启远程访问(如需指定 ip 替换%即可)
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option; flush privileges;
-
开启防火墙 3306 端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent # 开放3306端口
-
修改数据库默认字符集
vim /etc/my.cnf #======================= [client] default-character-set=utf8 [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock character-set-server=utf8 collation-server=utf8_general_ci # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
重启 mysqld
service mysqld restart
这篇关于CentOS7安装 mysql5.7的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-15MySQL教程:初学者必备的MySQL数据库入门指南
- 2024-11-15MySQL教程:初学者必看的MySQL入门指南
- 2024-11-04部署MySQL集群项目实战:新手入门教程
- 2024-11-04如何部署MySQL集群资料:新手入门指南
- 2024-11-02MySQL集群项目实战:新手入门指南
- 2024-11-02初学者指南:部署MySQL集群资料
- 2024-11-01部署MySQL集群教程:新手入门指南
- 2024-11-01如何部署MySQL集群:新手入门教程