rpm -qa | grep mysql
如果你查看出来有东西,可以使用下面命令将其删除(xxx 为文件全名)
rpm -e xxx
选择对应的包,右键复制下载链接
输入命令下载
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
mv /root/download/mysql-5.7.35-linux-glibc2.12-x86_64 /usr/local/mysql
groups mysql
添加用户组和用户
groupadd mysql && useradd -r -g mysql mysql
先进入目录/usr/local/mysql/mysql-5.7.35-linux-glibc2.12-x86_64
mkdir data
chown mysql:mysql -R data
然后重命名mysql-5.7.35-linux-glibc2.12-x86_64
mv mysql-5.7.35-linux-glibc2.12-x86_64 mysql5.7
mkdir etc
vim /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql/mysql5.7
datadir=/usr/local/mysql/mysql5.7/data
socket=/tmp/mysql.sock
log-error=/usr/local/mysql/mysql5.7/data/mysql.err
pid-file=/usr/local/mysql/mysql5.7/data/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
cd /usr/local/mysql/mysql-5.7/bin
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/mysql5.7/ --datadir=/usr/local/mysql/mysql5.7/data --user=mysql --initialize
cat /data/mysql.err
cp /usr/local/mysql/mysql5.7/support-files/mysql.server /etc/init.d/mysql
service mysql start
/usr/local/mysql/mysql5.7/bin/mysql -u root -p
ALTER USER "root"@"%" IDENTIFIED BY "123456";
ALTER USER USER() IDENTIFIED BY '123456';#MySQL 报错解决:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before
FLUSH PRIVILEGES; #刷新
use mysql; #选择访问mysql库
update user set host = '%' where user = 'root'; #使root能再任何host访问
FLUSH PRIVILEGES; #刷新
quit;
安装wget
yum -y install wget
ALTER USER USER() IDENTIFIED BY '123456';