【Linux】【MySQL】安装MySQL,版本5.7
本文环境:CentOS7,安装包放在/home/mysql
https://downloads.mysql.com/archives/community/
下载地址:https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
或者直接在Linux上wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
1、安装新版mysql前,需将系统自带的mariadb-lib卸载,rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
2、解压
cd /home/mysql
tar -xvf /home/mysql/mysql-5.7.32-1.el7.x86_64.rpm-bundle.tar
3、安装
rpm -ivh mysql-community-common-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm --force --nodeps
注:如果不带 --force --nodeps,可能发生下面错误
4、修改配置文件t添加下面内容,vi /etc/my.cnf
skip-grant-tables
character_set_server=utf8
init_connect='SET NAMES utf8'
说明:
skip-grant-tables:跳过登录验证
character_set_server=utf8:设置默认字符集UTF-8
init_connect='SET NAMES utf8':设置默认字符集UTF-8
5、启动服务
设置开机启动
进入mysql,mysql
6、设置密码,update mysql.user set authentication_string=password('123456') where user='root';
刷新权限,flush privileges;
7、退出mysql,重启mysql
exit;
systemctl stop mysqld.service
systemctl start mysqld.service
8、重新连接mysql,mysql -uroot -p123456