MySQL 安装
参考连接:https://www.cnblogs.com/jasonx1an/p/16690866.html
下载
下载网址:https://dev.mysql.com/downloads/mysql/
卸载 mariadb
-
查看 mariadb
rpm -qa|grep mariadb
-
卸载 mariadb
rpm -e mariadb-libs-5.5.68-1.el7.x86_64 --nodeps
-
再次查看
rpm -qa|grep mariadb
安装
将软件安装包上传到linux根目录下
创建文件夹
mkdir /usr/local/mysql
解压
tar -xvf mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar -C /usr/local/mysql
安装
cd /usr/local/mysql
rpm -ivh mysql-community-common-8.0.33-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.33-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.33-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm --nodeps --force
查看mysql安装包
rpm -qa | grep mysql
初始化数据库
mysqld --initialize
chown mysql:mysql /var/lib/mysql -R
systemctl start mysqld.service
systemctl enable mysqld
设置用户
生成数据库临时密码
cat /var/log/mysqld.log | grep password
进入数据库,输入临时密码
mysql -uroot -p
设置密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1234';
退出,使用设置的新密码登录
exit;
mysql -u root -p 1234
设置远程连接
create user 'root'@'%' identified with mysql_native_password by '1234';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
注意:需要关闭防火墙
通过连接工具连接