Centos服务器安装宝塔

1、可以登录到宝塔官网使用图形化界面安装:

https<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>www<span class="token punctuation">.</span>bt<span class="token punctuation">.</span>cn<span class="token operator">/</span>login<span class="token punctuation">.</span>html<span class="token operator">?</span><span class="token class-name">ReturnUrl</span><span class="token operator">=</span>https<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>www<span class="token punctuation">.</span>bt<span class="token punctuation">.</span>cn<span class="token operator">/</span>admin<span class="token operator">/</span>servers
https<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>www<span class="token punctuation">.</span>bt<span class="token punctuation">.</span>cn<span class="token operator">/</span>login<span class="token punctuation">.</span>html<span class="token operator">?</span><span class="token class-name">ReturnUrl</span><span class="token operator">=</span>https<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>www<span class="token punctuation">.</span>bt<span class="token punctuation">.</span>cn<span class="token operator">/</span>admin<span class="token operator">/</span>servers 
https://www.bt.cn/login.html?ReturnUrl=https://www.bt.cn/admin/servers

2、使用远程连接工具连接服务器,打开终端输入:

yum install <span class="token operator">-</span>y wget <span class="token operator">&&</span> wget <span class="token operator">-</span><span class="token class-name">O</span> install<span class="token punctuation">.</span>sh http<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>download<span class="token punctuation">.</span>bt<span class="token punctuation">.</span>cn<span class="token operator">/</span>install<span class="token operator">/</span>install_6<span class="token punctuation">.</span><span class="token number">0.</span>sh <span class="token operator">&&</span> sh install<span class="token punctuation">.</span>sh
yum install <span class="token operator">-</span>y wget <span class="token operator">&&</span> wget <span class="token operator">-</span><span class="token class-name">O</span> install<span class="token punctuation">.</span>sh http<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>download<span class="token punctuation">.</span>bt<span class="token punctuation">.</span>cn<span class="token operator">/</span>install<span class="token operator">/</span>install_6<span class="token punctuation">.</span><span class="token number">0.</span>sh <span class="token operator">&&</span> sh install<span class="token punctuation">.</span>sh 
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

在这里插入图片描述
默认yes即可,出现下面界面时即为安装成功。
在这里插入图片描述
参考:

https<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>blog<span class="token punctuation">.</span>csdn<span class="token punctuation">.</span>net<span class="token operator">/</span>m0_52316372<span class="token operator">/</span>article<span class="token operator">/</span>details<span class="token operator">/</span><span class="token number">125985490</span>
https<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>blog<span class="token punctuation">.</span>csdn<span class="token punctuation">.</span>net<span class="token operator">/</span>m0_52316372<span class="token operator">/</span>article<span class="token operator">/</span>details<span class="token operator">/</span><span class="token number">125985490</span> 
https://blog.csdn.net/m0_52316372/article/details/125985490

可以使用docker安装mysql,比较方便。也可以使用宝塔安装

宝塔安装完以后可以通过图形化界面安装mysql8,0,然后进行msyql重置密码
修改文件:

vi <span class="token operator">/</span>etc<span class="token operator">/</span>my<span class="token punctuation">.</span>cnf
vi <span class="token operator">/</span>etc<span class="token operator">/</span>my<span class="token punctuation">.</span>cnf 
vi /etc/my.cnf

按i在[mysqld]的最后一行添加:

skip<span class="token operator">-</span>grant<span class="token operator">-</span>tables
skip<span class="token operator">-</span>grant<span class="token operator">-</span>tables 
skip-grant-tables

然后按esc输入:wq保存退出
接着重启mysql

sudo systemctl start mysqld
sudo systemctl start mysqld 
sudo systemctl start mysqld

登录mysql,此时不需要密码了

mysql <span class="token operator">-</span>uroot <span class="token operator">-</span>p
mysql <span class="token operator">-</span>uroot <span class="token operator">-</span>p 
mysql -uroot -p

将密码设置为空:

update mysql<span class="token punctuation">.</span>user set authentication_string <span class="token operator">=</span> '' where user <span class="token operator">=</span> <span class="token char">'root'</span><span class="token punctuation">;</span> quit<span class="token punctuation">;</span> #退出mysql
update mysql<span class="token punctuation">.</span>user set authentication_string <span class="token operator">=</span> '' where user <span class="token operator">=</span> <span class="token char">'root'</span><span class="token punctuation">;</span> quit<span class="token punctuation">;</span> #退出mysql 
update mysql.user set authentication_string = '' where user = 'root'; quit; #退出mysql

再次修改my.cnf文件,去掉添加的skip-grant-tables
重启mysql

systemctl restart mysqld
systemctl restart mysqld 
systemctl restart mysqld

正式修改密码:

alter user <span class="token char">'root'</span>@'localhost' identified <span class="token keyword">with</span> <span class="token namespace">mysql_native_password</span> by <span class="token char">'新密码'</span><span class="token punctuation">;</span>
alter user <span class="token char">'root'</span>@'localhost' identified <span class="token keyword">with</span> <span class="token namespace">mysql_native_password</span> by <span class="token char">'新密码'</span><span class="token punctuation">;</span> 
alter user 'root'@'localhost' identified with mysql_native_password by '新密码';

刷新:

flush privileges<span class="token punctuation">;</span> quit<span class="token punctuation">;</span>
flush privileges<span class="token punctuation">;</span> quit<span class="token punctuation">;</span> 
flush privileges; quit;

mysql密码修改完成,注意mysql5和8的修改方式会有不同,这里修改的是mysql8。
远程连接失败:
在这里插入图片描述
mysql8需要创建远程连接的用户:

create user <span class="token char">'root'</span>@<span class="token char">'%'</span> identified by <span class="token char">'123456'</span><span class="token punctuation">;</span>
create user <span class="token char">'root'</span>@<span class="token char">'%'</span> identified by <span class="token char">'123456'</span><span class="token punctuation">;</span> 
create user 'root'@'%' identified by '123456';

赋予权限:

grant all privileges on <span class="token operator">*</span><span class="token punctuation">.</span>* <span class="token keyword">to</span> <span class="token char">'root'</span>@<span class="token char">'%'</span> <span class="token keyword">with</span> <span class="token namespace">grant</span> option<span class="token punctuation">;</span> <span class="token class-name">FLUSH</span> <span class="token constant">PRIVILEGES</span><span class="token punctuation">;</span>
grant all privileges on <span class="token operator">*</span><span class="token punctuation">.</span>* <span class="token keyword">to</span> <span class="token char">'root'</span>@<span class="token char">'%'</span> <span class="token keyword">with</span> <span class="token namespace">grant</span> option<span class="token punctuation">;</span> <span class="token class-name">FLUSH</span> <span class="token constant">PRIVILEGES</span><span class="token punctuation">;</span> 
grant all privileges on *.* to 'root'@'%' with grant option; FLUSH PRIVILEGES;

服务器端需要修改安全组,确保放行3306端口
在这里插入图片描述
如果使用了宝塔控制面板,需要在宝塔安全中添加规则:
在这里插入图片描述
之后就可以连接远程mysql了,注意,以上是针对mysql8的解决方案,mysql5及以下可能不同。

原文链接:https://blog.csdn.net/weixin_50944399/article/details/136108145

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享