MySQL使用rpm包安装

MySQL使用rpm包安装

安装

  1. 下载mysql rpm 安装包 。选择对应的操作系统版本 官网地址 下载对应的rpm包
mysql-community-common-5.7.29-1.el7.x86_64.rpm
mysql-community-libs-5.7.29-1.el7.x86_64.rpm
mysql-community-client-5.7.29-1.el7.x86_64.rpm
mysql-community-server-5.7.29-1.el7.x86_64.rpm
  1. 依次执行下面命令
rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm

报错

➜  tools rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        mysql-community-common(x86-64) >= 5.7.9 is needed by mysql-community-libs-5.7.29-1.el7.x86_64
        mariadb-libs is obsoleted by mysql-community-libs-5.7.29-1.el7.x86_64
➜  tools rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
➜  tools  rpm -e mariadb-libs-5.5.68-1.el7.x86_64
error: Failed dependencies:
        libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-9.el7.x86_64
        libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-9.el7.x86_64
➜  tools  rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
  1. 关于卸载
rpm -qa|grep mysql
rpm -e mysql-community-server-5.7.29-1.el7.x86_64.rpm
rpm -e mysql-community-client-5.7.29-1.el7.x86_64.rpm
rpm -e mysql-community-libs-5.7.29-1.el7.x86_64.rpm
rpm -e mysql-community-common-5.7.29-1.el7.x86_64.rpm

使用

  1. systemctl start mysqld 启动mysql
  2. grep password /var/log/mysqld.log 查看密码
  3. 登录mysql
  4. 修改密码
➜  tools grep password /var/log/mysqld.log
2022-09-18T04:02:24.435856Z 1 [Note] A temporary password is generated for root@localhost: YeBPgBelw3_O
➜  tools mysql -uroot -PYeBPgBelw3_O
mysql: [ERROR] Unknown suffix 'Y' used for variable 'port' (value 'YeBPgBelw3_O')
mysql: [ERROR] mysql: Error while setting value 'YeBPgBelw3_O' to 'port'
➜  tools mysql -uroot -p YeBPgBelw3_O
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
➜  tools mysql -uroot -pYeBPgBelw3_O
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.29

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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>
  1. 修改密码

在5.7版本不太友好,密码要求比较严格
如果你想要设置一个简单的测试密码的话,比如设置为root,会提示这个错误,报错的意思就是你的密码不符合要求
警告:由于密码将以明文形式发送到服务器,请使用ssl连接以确保密码安全。

➜  tools mysqladmin -u root -p password "xxxxx"
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysqladmin: unable to change password; error: 'Your password does not satisfy the current policy requirements'

修改设置密码的策略

➜  tools mysql -uroot -pYeBPgBelw3_O
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.29

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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>  set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql>  set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

再次设置密码成功

➜  tools mysqladmin -u root -p password "xxxxx"
Enter password:   #输入原始密码
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

你可能感兴趣的:(数据库技术,mysql,linux,服务器)