#1.卸载mariadb、mysql 相关软件
yum remove -y `rpm -aq mariadb*`
yum remove -y `rpm -aq mysql*`
#2.删除数据目录和配置文件
rm -rf /etc/my.cnf
rm -rf /var/lib/mysql
#3.测试是否卸载干净
rpm -aq mariadb*
rpm -aq mysql*
#4. 下载mysql5.7的安装包,上传到linux系统某个目录中,如 /home/mysql-install,然后使用命令
tar -xvf 解压 tar包
tar -xvf mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar
解压后
mysql-community-client-5.7.35-1.el7.x86_64.rpm
mysql-community-common-5.7.35-1.el7.x86_64.rpm
mysql-community-devel-5.7.35-1.el7.x86_64.rpm
mysql-community-embedded-5.7.35-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.35-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.35-1.el7.x86_64.rpm
mysql-community-libs-5.7.35-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm
mysql-community-server-5.7.35-1.el7.x86_64.rpm
mysql-community-test-5.7.35-1.el7.x86_64.rpm
3. 使用 rpm -ivh 命令按如下顺序安装mysql
rpm -ivh mysql-community-common-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm
在安装mysql-community-server-5.7.35-1.el7.x86_64.rpm 时出现如下错误解决办法:
error: Failed dependencies:
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.35-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.35-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.35-1.el7.x86_64安装 libaio:yum install libaio -y
在 Linux 中 MySQL 安装好了之后系统会自动的注册一个服务,服务名称叫做 mysqld,
可以通过以下命令操作 MySQL:
#启动 MySQL 服务:
systemctl start mysqld
#重启 MySQL 服务:
systemctl restart mysqld
#关闭 MySQL 服务:
systemctl stop mysqld
#查看MySql 服务状态:
systemctl status mysqld
#开机自动重启
systemctl enable mysqld
rpm 安装 MySQL 会自动生成一个随机密码,可在 /var/log/mysqld.log
这个文件中查找该密码
cat /var/log/mysqld.log
A temporary password is generated for root@localhost: xxxxxx
连接mysql,粘贴xxxxxxx这个随机密码 进行登录
mysql -u root -p
登录后,首先要修改root用户密码:
alter user root@localhost identified by 'Abc123456';FLUSH PRIVILEGES;
新增远程连接用户:
show databases;
use mysql;
show tables;CREATE USER '用户名'@'%' IDENTIFIED BY 'Abc123456';
GRANT ALL ON *.* TO '用户名'@'%';
FLUSH PRIVILEGES;
#binlog日志过期天数设置
#expire_logs_days=7
server-id = 1
binlog-do-db=crmeb
#binlog-do-db=
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
binlog-ignore-db=sys
#expire_logs_days=7
-----------------------------------------
查看3306端口:
netstat -talnp
-----------------------------------------
查看防火墙状态:
systemctl status firewalld
firewall-cmd --state
-----------------------------------------
虚拟机:192.168.124.101
mysql 在虚拟机上本地登录的密码:root Zzq123456
mysql 在虚拟机上远程登录的密码:root Zzq*123456
ps -ef |grep mysql