1.查询是否有残留软件
rpm -qa |grep mysql
rpm -qa |grep mariadb
2.上传解压并安装
root@kht:/kht# tar -xvf mysql-5.7.40-1.el7.x86_64.rpm-bundle.tar
mysql-community-client-5.7.40-1.el7.x86_64.rpm
mysql-community-common-5.7.40-1.el7.x86_64.rpm
mysql-community-devel-5.7.40-1.el7.x86_64.rpm
mysql-community-embedded-5.7.40-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.40-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.40-1.el7.x86_64.rpm
mysql-community-libs-5.7.40-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.40-1.el7.x86_64.rpm
mysql-community-server-5.7.40-1.el7.x86_64.rpm
mysql-community-test-5.7.40-1.el7.x86_64.rpm
#会看到很多rpm包,安装以下4个是必要的:如报错,后缀加 --force --nodeps
rpm -ivh mysql-community-common-
rpm -ivh mysql-community-libs-
rpm -ivh mysql-community-client-
rpm -ivh mysql-community-server-
#验证安装是否成功
root@kht:/kht# mysqladmin --version
mysqladmin Ver 8.42 Distrib 5.7.40, for Linux on x86_64
#启动
service mysqld start
#拿到默认密码
grep 'temporary password' /var/log/mysqld.log
#登录
mysql -uroot -p
3.修改密码等
#1.查看mysql密码策略
mysql> show variables like 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 4 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 1 |
+--------------------------------------+-------+
#2.修改密码规则以及修改密码
et global validate_password_length=4;
set global validate_password_policy=0;
set password = password('root');
#3.查看远程都能权限
mysql> use mysql;
Database changed
mysql> select user,host from user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
#4.授权远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH PRIVILEGES;
4.常见问题解决
4.1使用命令mysql -uroot -p连接mysql数据库报错:
error while loading shared libraries: libncurses.so.5: cannot open shared object file
解决办法
#1.没有libncurses.so.5,可能有libncurses.so不同版本的文件,使用如下命令查看
find / -name 'libncurses.so*'
2.#查找,如找到的是
/usr/lib/x86_64-linux-gnu/libncurses.so.6.2
3.#进入对应的目录
cd /usr/lib/x86_64-linux-gnu/
4.建立软连接
ln -s libncurses.so.6.2 libncurses.so.5
标签:x86,tar,MySql5.7,community,64,bundle,mysql,password,rpm
From: https://www.cnblogs.com/khtt/p/16888033.html