查看: 669|回复: 0
打印 上一主题 下一主题

[MySQL] Ubuntu19安装默认MySQL5.7的操作步骤

[复制链接]
  • TA的每日心情
    开心
    2017-7-5 20:14
  • 签到天数: 4 天

    [LV.2]偶尔看看I

    1698

    主题

    1707

    帖子

    7350

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    7350
    跳转到指定楼层
    楼主
    发表于 2019-4-27 13:24:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

    一 安装MySQL,执行下面的命令
    1. sudo apt-get update
    2. sudo apt-get install mysql-server -y
    复制代码

    二 配置MySQL
    2.1 安装配置
    1. sudo mysql_secure_installation
    复制代码

    1. #1
    2. VALIDATE PASSWORD PLUGIN can be used to test passwords
    3. and improve security. It checks the strength of password
    4. and allows the users to set only those passwords which are
    5. secure enough. Would you like to setup VALIDATE PASSWORD plugin?
    6. Press y|Y for Yes, any other key for No:N (我的选项)

    7. #2
    8. Please set the password for root here.
    9. New password:(输入密码)
    10. Re-enter new password:(重复输入)

    11. #3
    12. By default, a MySQL installation has an anonymous user,
    13. allowing anyone to log into MySQL without having to have
    14. a user account created for them. This is intended only for
    15. testing, and to make the installation go a bit smoother.
    16. You should remove them before moving into a production
    17. environment.
    18. Remove anonymous users? (Press y|Y for Yes, any other key for No) :N (我的选项)

    19. #4
    20. Normally, root should only be allowed to connect from
    21. 'localhost'. This ensures that someone cannot guess at
    22. the root password from the network.
    23. Disallow root login remotely? (Press y|Y for Yes, any other key for No) :Y (我的选项)

    24. #5
    25. By default, MySQL comes with a database named 'test' that
    26. anyone can access. This is also intended only for testing,
    27. and should be removed before moving into a production
    28. environment.
    29. Remove test database and access to it? (Press y|Y for Yes, any other key for No) :N (我的选项)

    30. #6
    31. Reloading the privilege tables will ensure that all changes
    32. made so far will take effect immediately.
    33. Reload privilege tables now? (Press y|Y for Yes, any other key for No) :Y (我的选项)
    复制代码

    2.2 检查mysql服务状态
    1. systemctl status mysql.service
    复制代码

    2.3 登录并修改root的plugin
    1. mysql -uroot
    2. select user,plugin from user;
    复制代码
    修改root的plugin为mysql_native_password
    1. update user set plugin='mysql_native_password' where user='root';
    2. update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root';
    3. flush privileges;
    复制代码

    三 运行
    1. sudo service mysql stop
    2. sudo service mysql start
    复制代码

    四 连接
    1. mysql -h127.0.0.1 -uroot -p
    复制代码
    然后输入密码即可

    资源帝国 - 论坛版权1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关
    2、本站所有主题由该帖子作者发表,该帖子作者与资源帝国享有帖子相关版权
    3、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者和资源帝国的同意
    4、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任
    5、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
    6、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
    7、资源帝国管理员和版主有权不事先通知发贴者而删除本文

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|资源帝国 ( 皖ICP备14009953号 )?

    GMT+8, 2019-8-11 01:51 , Processed in 0.056352 second(s), 29 queries .

    Powered by Discuz! X3.2

    ? 2001-2017 Comsenz Inc.

    快速回复 返回顶部 返回列表