centos7安装mysql
2022/2/3 19:42:23
本文主要是介绍centos7安装mysql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
- 准备两台centos主机(这里两台主机IP为192.168.2.11和192.168.2.12)
- 到mysql官网下载mysql5.7 bundle
mysql-5.7.37-1.el7.x86_64.rpm-bundle.tar - 解压mysql5.7
包含10个文件
mysql-community-client-5.7.37-1.el7.x86_64.rpm
mysql-community-common-5.7.37-1.el7.x86_64.rpm
mysql-community-devel-5.7.37-1.el7.x86_64.rpm
mysql-community-embedded-5.7.37-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.37-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.37-1.el7.x86_64.rpm
mysql-community-libs-5.7.37-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm
mysql-community-server-5.7.37-1.el7.x86_64.rpm
mysql-community-test-5.7.37-1.el7.x86_64.rpm - 删除mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64 - 安装
rpm -ivh *.rpm - 查看mysql-server安装的文件列表
rpm -ql mysql-community-server-5.7.37 - 查看默认密码
cat /var/log/mysqld.log |grep password[root@slave1 mysql57]# cat /var/log/mysqld.log |grep password 2022-02-03T09:59:22.090885Z 1 [Note] A temporary password is generated for root@localhost: AJDtlg*kM1W1
- 关闭validate_password插件
vim /etc/my.cnf最后添加validate_password=OFF# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [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 # 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 validate_password=OFF #新添加
-
登录mysql
mysql -uroot -p回车输入/var/log/mysqld.log中的密码 -
设置密码(需要关闭密码验证插件validate_password=OFF)
set password for root@localhost=password('123456'); -
查看mysql现有账号
use mysql;
mysql> select user,host from user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
3 rows in set (0.00 sec) -
添加远程账号
mysql> grant all privileges on *.* to root@'%' identified by 'admin888';
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) -
centos添加3306端口
[root@slave1 mysql57]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[root@slave1 mysql57]# firewall-cmd --reload
success
这篇关于centos7安装mysql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 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集群:新手入门教程
- 2024-11-01部署MySQL集群学习:新手入门教程
- 2024-11-01部署MySQL集群入门:新手必读指南