1、下载Yum资源包
下载地址:https://dev.mysql.com/downloads/repo/yum/
注:本教程使用centos7操作系统,下载Red Hat版本
2.更新Yum源,开始安装
[root@host]# wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
[root@host]# rpm -ivh mysql80-community-release-el8-1.noarch.rpm
[root@host]# yum update
[root@host]# yum install mysql-server
3.权限设置
[root@host]# chown mysql:mysql -R /var/lib/mysql
4.初始化MySQL
[root@host]# mysqld --initialize
5.验证安装,启动MySQL
[root@host]# mysql --version
出现版本号表示安装成功
[root@host]# systemctl start mysqld
6.查看MySQL运行状态
[root@host]# systemctl status mysqld
7.设置root用户密码
由于linux安装MySQL之后,root用户默认没有密码,所以需要手动设置密码
[root@host]# mysqladmin -u root password "new_password";
注:new_password
处填写具体的密码
8.开启MySQL远程连接
- 登录MySQL控制台
[root@host]# mysql -u root -p
Enter password:*******
- 开启MySQL远程权限
mysql> user mysql;
Database changed
mysql> grant all privileges on *.* to root@'%' identified by "password"; # 添加权限用户
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges; # 刷新设置
Query OK, 0 rows affected (0.00 sec)mysql> select host,user,password from user;
+-------------------------+------+-------------------------------------------+
| host | user | password |
+-------------------------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| izuf6agiqhn4ryphdkzzy5z | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | | |
| izuf6agiqhn4ryphdkzzy5z | | |
| % | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-------------------------+------+-------------------------------------------+
7 rows in set (0.00 sec)
3 rows in set (0.00 sec)
注:password
处填写具体的root远程用户密码
服务器远程注意还需使防火墙打开3306端口,防火墙操作可参考此链接
https://blog.csdn.net/qq_40981137/article/details/107334096