ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

ubuntu20.04安装mysql8并配置远程访问

2021-05-16 18:29:33  阅读:372  来源: 互联网

标签:ubuntu20.04 mysql8 MySQL other key mysql password root 远程


环境:

ubuntu20.04

8.0.25-0ubuntu0.20.04.1

1.安装mysql

apt-get install mysql-server
apt-get install mysql-client

2.配置mysql

sudo mysql_secure_installation

按下面流程配置完成,主要是设置密码

root@ailyun:~# sudo mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: n
Please set the password for root here.

New password:

Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : n

 ... skipping.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

3.配置远程登入

// 登录数据库
mysql -u root -p
// 选择数据库
mysql> use mysql;
// 更改加密方式,passwd为数据库密码
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'pwsswd';
// 修改root用户为所有ip都可访问
update user set host='%' where user='root';
// 开户root用户的远程访问权限
grant all on *.* to 'root'@'%';
// 更新权限
flush privileges;

 修改配置文件

// 停止mysql服务,不然后配置文件不能保存
service mysql stop
// 打开配置文件
vim /etc/mysql/mysql.conf.d/mysqld.cnf

// 注释下面一行
# bind-address = 127.0.0.1

// 再启动mysql服务
service mysql start

 打开mysql workbench,选择Database -> Connect to Database,输入ip端口,用户名密码

 

标签:ubuntu20.04,mysql8,MySQL,other,key,mysql,password,root,远程
来源: https://blog.csdn.net/sy84436446/article/details/116899129

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有