安装
- 下载mysql rpm 安装包 。选择对应的操作系统版本 官网地址 下载对应的rpm包
mysql-community-common-5.7.29-1.el7.x86_64.rpmmysql-community-libs-5.7.29-1.el7.x86_64.rpmmysql-community-client-5.7.29-1.el7.x86_64.rpmmysql-community-server-5.7.29-1.el7.x86_64.rpm
- 依次执行下面命令
rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpmrpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpmrpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpmrpm -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.rpmwarning: mysql-community-libs-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYerror: 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 mariadbmariadb-libs-5.5.68-1.el7.x86_64➜ tools rpm -e mariadb-libs-5.5.68-1.el7.x86_64error: 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
- 关于卸载
rpm -qa|grep mysqlrpm -e mysql-community-server-5.7.29-1.el7.x86_64.rpmrpm -e mysql-community-client-5.7.29-1.el7.x86_64.rpmrpm -e mysql-community-libs-5.7.29-1.el7.x86_64.rpmrpm -e mysql-community-common-5.7.29-1.el7.x86_64.rpm
使用
- systemctl start mysqld 启动mysql
- grep password /var/log/mysqld.log 查看密码
- 登录mysql
- 修改密码
➜ tools grep password /var/log/mysqld.log2022-09-18T04:02:24.435856Z 1 [Note] A temporary password is generated for root@localhost: YeBPgBelw3_O➜ tools mysql -uroot -PYeBPgBelw3_Omysql: [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_OEnter password:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)➜ tools mysql -uroot -pYeBPgBelw3_Omysql: [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 3Server version: 5.7.29Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
- 修改密码
在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_Omysql: [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 10Server version: 5.7.29Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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> exitBye
再次设置密码成功
➜ 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.
来源地址:https://blog.csdn.net/Erice_s/article/details/126918365