centos7.9安装mysql5.7

由于个人配置的服务器性能比较差,容量也不够,没有使用docker或宝塔安装mysql

实操时间: 2024-07-05
环境:
1、centos 7.9;
2、5.7.44 MySQL Community Server (GPL);
3、腾讯云

参考(有细节差异):
https://blog.csdn.net/weixin_44304847/article/details/124349013?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522172015147316800182726212%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=172015147316800182726212&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allsobaiduend~default-2-124349013-null-null.142v100control&utm_term=centos7.9%E5%AE%89%E8%A3%85mysql5.7&spm=1018.2226.3001.4187

安装mysql5.7

下载yum仓库;安装yum仓库;安装mysql-community-server;移除仓库;查看mysql服务状态;启动mysql服务:
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql-community-server

yum -y remove mysql57-community-release-el7-10.noarch

systemctl status mysqld.service

systemctl start mysqld.service

登入mysql

mysql -u root

[root@VM-16-14-centos ~]# mysql -u root 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.44 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

设置root密码

alter user 'root'@'localhost' identified by '.@urpsw@.';


触发了报错《ERROR 3009 (HY000)》:

ERROR 3009 (HY000): Column count of mysql.user is wrong. Expected 45, found 43. Created with MySQL 50651, now running 50744. Please use mysql_upgrade to fix this error.

进行修复,步骤1:
REPAIR TABLE mysql.user;

mysql> REPAIR TABLE mysql.user;
+------------+--------+----------+----------+
| Table      | Op     | Msg_type | Msg_text |
+------------+--------+----------+----------+
| mysql.user | repair | status   | OK       |
+------------+--------+----------+----------+
1 row in set (0.00 sec)

步骤2:

mysql升级 参考(有细节差异):https://www.cnblogs.com/liufofu/p/7722254.html

whereis mysql_upgrade

[root@VM-16-14-centos local]# whereis mysql_upgrade 
mysql_upgrade: /usr/bin/mysql_upgrade /usr/share/man/man1/mysql_upgrade.1.gz

/usr/bin/mysql_upgrade

[root@VM-16-14-centos local]# /usr/bin/mysql_upgrade
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.engine_cost                                  OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Upgrading the sys schema.
Checking databases.
sys.sys_config                                     OK
Upgrade process completed successfully.
Checking if update is needed.
[root@VM-16-14-centos local]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.44 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

修复完成《ERROR 3009 (HY000)》


重新设置密码
alter user 'root'@'localhost' identified by '.@urPsw.';

mysql> alter user 'root'@'localhost' identified by '.@urPsw.';
Query OK, 0 rows affected (0.00 sec)

授权访问

grant all privileges on *.* to 'root'@'%' identified by 'MySQL%57' with grant option;

mysql> grant all privileges on *.* to 'root'@'%' identified by 'MySQL%57' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值