查看删除系统自带数据库
查看:rpm -qa|grep mariadb*
删除:rpm -e mariadb-libs-5.5.68_x86_64
强制删除:rpm -e --nodeps mariadb-libs-5.5.68_x86_64
1、下载MySQL的RPM包:访问MySQL官方网站(https://dev.mysql.com/downloads/mysql/)并选择适合CentOS 7的RPM包。选择正确的版本(通常是"Red Hat Enterprise Linux 7 (x86, 64-bit)"),然后下载对应的RPM包。
2、安装mysql所需依赖包
yum -y install wget
yum -y install libaio
3、上次mysql包并安装
rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm
如安装还提示依赖需要忽略安装
rpm -ivh --nodeps mysql-community-server-8.0.25-1.el7.x86_64.rpm
4、启动MySQL服务:安装完成后,使用以下命令启动MySQL服务:
sudo systemctl start mysqld
5、配置MySQL:首次启动MySQL后,会生成一个临时密码。使用以下命令来查看临时密码:
sudo grep 'temporary password' /var/log/mysqld.log
首次启动可日志查看密码文件cat /var/log/mysql.log
6、运行MySQL安全脚本:为了提高MySQL的安全性,运行MySQL提供的安全脚本,并按照提示进行密码修改和其他安全设置:
sudo mysql_secure_installation
7、设置MySQL开机自启动:使用以下命令将MySQL设置为开机自启动:
sudo systemctl enable mysqld
8、/usr/bin ./mysql -uxxx -pxxx查看数据库
修改密码:ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
密码不符合策略要求
9、设置MySQL开机自启动:使用以下命令将MySQL设置为开机自启动
sudo systemctl enable mysqld
10、卸载mysql
停服务:systemctl stop mysqld
查看安装包、卸载:查看rpm -qa|grep mysql* 卸载:rpm -e 包名
删除配置文件:rm -rf /etc/my.cnf
删除缓存文件:rm -rf /var/lib/mysql
11、客户端访问(navicat15)
is not allowed to connect to this MySQL server(不允许连接到这个MySQL服务器)
本地telnet端口不被允许访问
./mysql -uuser -ppassword
use mysql;
select host from user where user='root';
update user set host = '%' where user ='root';
flush privileges;
再次连接navicat成功
错误信息补充:
1、yum install libaio
cat /var/log/mysql/error.log
- 确保 errmsg.sys 文件与当前使用的 MySQL 版本匹配。
- 删除数据目录(/var/lib/mysql/)中的所有文件,确保它是空的。
- 检查数据目录的权限,确保 MySQL 进程具有足够的权限写入该目录。
- 尝试重新启动 MySQL。
- libaio依赖包安装