centos7安装 MySql5.7.bundle.tar

1.查询是否有残留软件

[root@kht118 kht]# rpm -aq|grep mysql
[root@kht118 kht]# rpm -aq|grep mariadb
mariadb-libs-5.5.65-1.el7.x86_64
[root@kht118 kht]# yum remove -y mariadb-libs-5.5.65-1.el7.x86_64
[root@kht118 mysql]# find / -name *mysql*
[root@kht118 mysql]# find / -name *mariadb*
[root@kht118 mysql]# yum install libaio -y

2.上传解压并安装

root@kht:/kht# tar -xf 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-5
rpm -ivh mysql-community-client-
rpm -ivh mysql-community-server-
#验证安装是否成功
[root@kht118 kht]# mysqladmin --version
mysqladmin  Ver 8.42 Distrib 5.7.40, for Linux on x86_64
#启动
service mysqld start
systemctl start mysqld
#拿到默认密码
grep 'temporary password' /var/log/mysqld.log
#登录
mysql -uroot -p

3.修改密码等

#1.查看mysql密码策略,需要先进行密码修改
mysql>set password = password('KHTkht123456!');
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.修改密码规则以及修改密码
set global validate_password_length=4;
set global validate_password_policy=0;
set password = password('kht123');
#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 'kht123' with grant option; 
grant all privileges on *.* to 'root'@'%' with grant option; 
flush privileges;

4.mysql卸载

#1.查找(ubuntu查找rpm -a -q)
[root@kht118 kht]# rpm -aq|grep mysql
mysql-community-server-5.7.40-1.el7.x86_64
mysql-community-common-5.7.40-1.el7.x86_64
mysql-community-client-5.7.40-1.el7.x86_64
mysql-community-libs-5.7.40-1.el7.x86_64
2.#执行卸载命令,按照以下顺序卸载
rpm -e mysql-community-server-
rpm -e mysql-community-client-
rpm -e mysql-community-libs-
rpm -e mysql-community-common-
3.#卸载后查询验证
[root@kht118 kht]# rpm -aq|grep mysql
4.#说明,使用以下命令可以忽略依赖直接卸载
rpm -e [package name] -nodeps
5.#需要删除的目录文件
[root@kht101 mysql5.7.39]# find / -name mysql
/etc/selinux/targeted/active/modules/100/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/share/mysql

6.常见问题解决(ubuntu可能存在以下问题)

6.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
posted @ 2022-11-14 09:29  kht  阅读(159)  评论(0编辑  收藏  举报