Linux(CentOS)使用安装包安装MySQL

Linux(CentOS)使用安装包安装MySQL

1、解压上传安装包

tar -xvf mysql-8.0.25-1.el7.x86_64.rpm-bundle.tar

2、安装

  
[root@ueserver217 mysqldev]# rpm -ivh mysql-community-common-8.0.25-1.el7.x86_64.rpm --nodeps --force
警告:mysql-community-common-8.0.25-1.el7.x86_64.rpm:V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-common-8.0.25-1.e################################# [100%]
[root@ueserver217 mysqldev]# rpm -ivh mysql-community-libs-compat-8.0.25-1.el7.x86_64.rpm --nodeps --force 
警告:mysql-community-libs-compat-8.0.25-1.el7.x86_64.rpm:V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-libs-compat-8.0.2################################# [100%]
/sbin/ldconfig: 文件 /lib/libsecx.so 己被截断

/sbin/ldconfig: 文件 /lib64/libsecx.so 己被截断

[root@ueserver217 mysqldev]# rpm -ivh mysql-community-client-8.0.25-1.el7.x86_64.rpm --nodeps --force 
警告:mysql-community-client-8.0.25-1.el7.x86_64.rpm:V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-client-8.0.25-1.e################################# [100%]
[root@ueserver217 mysqldev]# rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm --nodeps --force 
警告:mysql-community-server-8.0.25-1.el7.x86_64.rpm:V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-server-8.0.25-1.e################################# [100%]
[root@ueserver217 mysqldev]#  rpm -qa | grep mysql
mysql-community-libs-compat-8.0.25-1.el7.x86_64
mysql-community-server-8.0.25-1.el7.x86_64
mysql-community-client-8.0.25-1.el7.x86_64
mysql-community-common-8.0.25-1.el7.x86_64
[root@ueserver217 mysqldev]# mysqld --initialize

[root@ueserver217 mysqldev]# 
[root@ueserver217 mysqldev]# 
[root@ueserver217 mysqldev]# mysqld --initialize;
[root@ueserver217 mysqldev]# chown mysql:mysql /var/lib/mysql -R;
[root@ueserver217 mysqldev]# systemctl start mysqld.service;
^C
[root@ueserver217 mysqldev]# ^C
[root@ueserver217 mysqldev]# chown mysql:mysql /var/lib/mysql -R
[root@ueserver217 mysqldev]# systemctl start mysqld.service
[root@ueserver217 mysqldev]# systemctl  enable mysqld
[root@ueserver217 mysqldev]# cat /var/log/mysqld.log | grep password 
2023-11-24T08:12:57.014010Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: =&Zy%;Xk1roe
[root@ueserver217 mysqldev]# mysql -uroot -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@ueserver217 mysqldev]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.25

Copyright (c) 2000, 2021, 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> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'
    -> ;
Query OK, 0 rows affected (0.10 sec)

mysql> exit
Bye
[root@ueserver217 mysqldev]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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> exit
Bye

6、 安装完成后,无法被他人连接

Host ‘xxx.xxx.xxx.xxx’ is not allowed connect to this mysql server

6.1、授权法

-- 登录
mysql -u root -p rootpassword;

--  赋予给指定IP连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'xxx.xxx.xxx.xxx' IDENTIFIED BY 'rootPassword' WITH GRANT OPTION;
-- 刷新数据库命令必须执行!!
FLUSH   PRIVILEGES;

示例


[root@ueserver217 mysqldev]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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> GRANT ALL PRIVILEGES ON *.* TO 'root'@'xxx.xxx.xxx.xxx' IDENTIFIED BY 'root' WITH GRANT OPTION;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY 'root' WITH GRANT OPTION' at line 1
mysql> exit
Bye
[root@ueserver217 mysqldev]# clear
[root@ueserver217 mysqldev]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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> FLUSH   PRIVILEGES;
Query OK, 0 rows affected (0.09 sec)

mysql> exit
Bye
  • 9
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值