如果按照此文章,请下载这个tar包 点击下载 ,里面包含5个文件,然后上传到Linux
使用下面的命令进行解压
tar -xvf MySQL5.7.tar
删除旧版本MySQL的残留信息
rm -rf /usr/lib/mysql
rm -rf /usr/include/mysql
rm -rf /etc/my.cnf
rm -rf /var/lib/mysql
rm -rf /usr/share/mysql
检测是否安装和删除mysql
rpm -qagrep -i mysql
rpm -e --nodeps mysql-libs
检测是否安装和删除mariadb
rpm -qagrep mariadb
rpm -e --nodeps mariadb-libs
安装环境
yum install -y perl.x86_64
yum install -y libaio.x86_64
yum install -y net-tools.x86_64
MySQL包的安装
rpm -ivh mysql-community-common-5.7.42-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.42-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.42-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.42-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.42-1.el7.x86_64.rpm
rpm -ivh mysql-community-*
修改my.cnf文件,添加配置信息
vi /etc/my.cnf
按i进入插入模式,添加下面的代码
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
character_set_server=utf8
按Esc退出插入模式,输入:wq
保存退出
创建mysqld.pid存放目录,授予权限
mkdir -p /var/run/mysqld/
chown -R mysql:mysql /var/lib/mysql
启动MySQL服务
systemctl start mysqld&
查看初始密码并登录Mysql(登录Mysql,再输入初始密码)
grep 'temporary password' /var/log/mysqld.log
登录Mysql,再输入初始密码
mysql -u root -p
修改默认密码
// 设置新密码的验证策略为0,表示最低
set global validate_password_policy=0;
// 设置新密码的长度最小值为1位
set global validate_password_length=1;
// 设置新密码为123456
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
下面是方便复制粘贴的,上面是解释
set global validate_password_policy=0;
set global validate_password_length=1;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
解决远程登录1130报错
use mysql;
select host from user where user='root';
update user set host = '%' where user ='root';
flush privileges;
select 'host' from user where user='root';
exit;
在centos中设置MySQL开机启动
systemctl enable mysqld.service
作者:404_502
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0协议。转载请注明文章地址及作者