经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » MySQL » 查看文章
Ubuntu 18.04.4安装mysql的过程详解 亲测可用
来源:jb51  时间:2021/12/31 12:58:34  对本文有异议
  1. 1 sudo apt-get update
  1. 2 sudo apt-get install mysql-server
  1. 3 sudo mysql_secure_installation # 初始化配置
  2. #1
  3. VALIDATE PASSWORD PLUGIN can be used to test passwords...
  4. Press y|Y for Yes, any other key for No: N (我的选项)
  5. #2
  6. Please set the password for root here...
  7. New password: (输入密码)
  8. Re-enter new password: (重复输入)
  9. #3
  10. By default, a MySQL installation has an anonymous user,
  11. allowing anyone to log into MySQL without having to have
  12. a user account created for them...
  13. Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (我的选项)
  14. #4
  15. Normally, root should only be allowed to connect from
  16. 'localhost'. This ensures that someone cannot guess at
  17. the root password from the network...
  18. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y (我的选项)
  19. #5
  20. By default, MySQL comes with a database named 'test' that
  21. anyone can access...
  22. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (我的选项)
  23. #6
  24. Reloading the privilege tables will ensure that all changes
  25. made so far will take effect immediately.
  26. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (我的选项)
  27. 4 systemctl status mysql.service # 检查服务器状态
  1. 4 systemctl status mysql.service # 检查服务器状态

running代表无问题

  1. 5 修改mysql 端口号以及将监听地址改为所有
  2.  
  3. vim /etc/mysql/mysql.conf.d/mysqld.cnf # 编辑配置文件
  4. bind-address = 0.0.0.0 #将监听ip修改为所有
  5. port = 3388 # 监听端口修改为3388,可以不改我这是为了安全
  6. 修改完毕之后重启服务
  7. systemctl restart mysql.service
  1. 6 开放mysql远程访问
  2. 1 登录数据库
  3. mysql -u root -p
  4.  
  5. 2 切换到数据库mysql
  6. use mysql
  7. 3 删除匿名用户
  8. delete from user where user='';
  9. 4 增加允许远程访问的用户或者允许现有用户的远程访问
  10. root授予在任意主机(%)访问任意数据库的所有权限
  11. mysql> grant all privileges on *.* to 'root'@'%' identified by '这里替换成你想要设置的密码' with grant option;
  12. flush privileges;
  13. 5 退出数据库
  14. mysql> exit
  15. 6 重启数据库
  16. sudo service mysql restart

到此这篇关于Ubuntu 18.04.4安装mysql的过程详解 亲测可用的文章就介绍到这了,更多相关Ubuntu 18.04.4安装mysql内容请搜索w3xue以前的文章或继续浏览下面的相关文章希望大家以后多多支持w3xue!

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号