安装之前别忘了开放服务器3306端口https://blog.csdn.net/qq_25851237/article/details/109554885
将mysql-8.0.29-linux-glibc2.12-x86_64.tar.xz安装包上传至服务器/usr/local/
目录
tar -xzvf mysql-8.0.29-linux-glibc2.12-x86_64.tar.xz
mv mysql-8.0.29-linux-glibc2.12-x86_64.tar.xz mysql
cd mysql
mkdir data
cd /usr/local/mysql/bin
./mysqld --user=root --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/ --initialize
红框是临时登录密码
cd /usr/local/mysql
cp -a ./support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin
启动MySQL:
service mysql start
service mysql status
#登录
mysql mysql -uroot -p 输入上面的临时密码
修改root密码
#执行命令,修改后上面临时密码失效,新密码为root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
#使密码生效
flush privileges;
use mysql;
修改远程连接
update user set Host='%' where User='root';
flush privileges;
exit;
开启3306端口
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --reload
若开启端口报错
则执行
systemctl start firewalld
然后再执行上述开启端口命令
引用文件:
https://www.cnblogs.com/kire-cat/p/16361559.html
https://www.javazxz.com/thread-11184-1-1.html
http://t.zoukankan.com/leblog-p-13173356.html
报错:
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
https://www.likecs.com/show-205099066.html