ubuntu20.04安装mysql8并配置远程访问
2021/5/16 19:25:35
本文主要是介绍ubuntu20.04安装mysql8并配置远程访问,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
环境:
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并配置远程访问的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-25MySQL报错Duplicate entry '0' for key 'PRIMARY'
- 2024-05-29阿里 Canal 实时同步 MySQL 增量数据至 ClickHouse 数据库
- 2024-05-24在Linux下管理MySQL的大小写敏感性
- 2024-04-26MySQL查出时间比实际晚8小时的解决方案
- 2024-04-01JPA不识别MySQL的枚举类型
- 2024-03-30mysql数据库表卡死解决方法
- 2024-03-15MySQL多数据源笔记5-ShardingJDBC实战
- 2024-03-11natural join mysql
- 2024-03-11关于VS2017,VS2015 中利用 EF使用Mysql 不显示数据源问题解决方案
- 2024-02-26mysql 阿里云xb后缀备份文件恢复-icode9专业技术文章分享