centos7.9安装MySQL8.0.28,并使用navicat连接Mysql

centos7.9安装MySQL8.0.28

1、下载解压安装包
https://downloads.mysql.com/archives/community/

在这里插入图片描述

2、检查自己的环境是否存在mariadb
[root@VM-24-3-centos /]# rpm -qa|grep mariadb
[root@VM-24-3-centos /]# mariadb-libs-5.5.68-1.el7.x86_64
[root@VM-24-3-centos /]# rpm -e --nodeps mariadb-libs
[root@VM-24-3-centos /]# rpm -qa|grep mariadb
[root@VM-24-3-centos /]#
3、依次安装下列几个包
[root@VM-24-3-centos mysql]# rpm -ivh mysql-community-common-8.0.28-
[root@VM-24-3-centos mysql]# rpm -ivh mysql-community-client-plugins-8.0.28-
[root@VM-24-3-centos mysql]# rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm 
[root@VM-24-3-centos mysql]# rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm 
[root@VM-24-3-centos mysql]# rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm 
[root@VM-24-3-centos mysql]# rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm 
4、安装完成初始化
[root@VM-24-3-centos mysql]# mysqld --initialize --console
5、修改MySQL的所属组和所有者
[root@VM-24-3-centos mysql]# chown -R mysql:mysql /opt/mysql
6、启动mysql
[root@VM-24-3-centos mysql]# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
#提示启动失败则根据日志文件排查错误 cat /var/log/mysqld.log  命令查看日志
#根据日志信息发现下图错误信息

在这里插入图片描述

#ibdata1必须可写,则查看该文件路径,并修改其权限
[root@VM-24-3-centos mysql]# find / -name ibdata1
/var/lib/mysql/ibdata1
[root@VM-24-3-centos mysql]# chmod -R 777 /var/lib/mysql
#修改完成后再次启动,
[root@VM-24-3-centos mysql]# systemctl start mysqld
#启动成功
[root@VM-24-3-centos mysql]# 
7、在日志文件中查看安装好初始化密码
[root@VM-24-3-centos mysql]# cat /var/log/mysqld.log|grep localhost
2022-12-28T07:47:32.089655Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: hAwl))w15>Z1
8、连接数据库
[root@VM-24-3-centos mysql]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@VM-24-3-centos mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.28

Copyright (c) 2000, 2022, 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密码
mysql> alter user 'root'@'localhost' identified by '283532';
Query OK, 0 rows affected (0.01 sec)
#退出数据库使用刚才修改的密码登录
[root@VM-24-3-centos mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> exit
Bye
[root@VM-24-3-centos mysql]# 

9、使用navicat for mysql连接数据库

在这里插入图片描述

#连接时出现上图错误或者是无法连接到主机,则按如下操作
[root@VM-24-3-centos mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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> use mysql;
Database changed
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

#此时如果出现错误则执行则将 localhost 改为 % 再次执行
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '283532';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
#
mysql> alter user 'root'@'%' identified with mysql_native_password by '283532';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> 




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值