linux(ubuntu 21.10): apt-get安装mysql8.0.27
2023-09-14 08:59:32 时间
一,安装mysql8
1,更新apt源:
root@lhdpc:~# apt-get update
2,安装mysql
root@lhdpc:~# apt-get install mysql-server
3,检查mysql的状态:
root@lhdpc:~# systemctl status mysql.service ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2021-12-20 18:15:45 CST; 38s ago Process: 255962 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS) Main PID: 255970 (mysqld) Status: "Server is operational" Tasks: 38 (limit: 4588) Memory: 352.8M CPU: 2.455s CGroup: /system.slice/mysql.service └─255970 /usr/sbin/mysqld 12月 20 18:15:43 lhdpc systemd[1]: Starting MySQL Community Server... 12月 20 18:15:45 lhdpc systemd[1]: Started MySQL Community Server.
状态已是运行中
说明:安装完成后
mysql的配置文件位于:
root@lhdpc:~# ll /etc/mysql/mysql.conf.d/mysqld.cnf -rw-r--r-- 1 root root 2220 3月 13 2021 /etc/mysql/mysql.conf.d/mysqld.cnf
说明:此时可以不用密码登录mysql,
因为它使用my.cnf中的默认密码连接
此账号位于:
root@lhdpc:~# more /etc/mysql/debian.cnf
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,用mysql_secure_installation进行mysql初始化
1,执行mysql_secure_installation
root@lhdpc:~# mysql_secure_installation
会有一系列的问题回答:
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
是否做密码的强度校验?选n,生产环境中建议设置一个高强度的密码
Please set the password for root here. New password: Re-enter new password:
在此处输入两次mysql的root账号密码
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y Success.
此处输入Y,用来删除匿名用户
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N ... skipping.
是否禁止root账号远程连接,选n,允许远程连接
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n
是否删除test数据库,选n,不删,留着
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y Success.
是否重新加载权限表,选Y,加载
2,测试效果:用刚才设置的root密码登录
root@lhdpc:~# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 8.0.27-0ubuntu0.21.10.1 (Ubuntu) Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
三,查看已安装mysql的版本:
root@lhdpc:~# whereis mysqld mysqld: /usr/sbin/mysqld /usr/share/man/man8/mysqld.8.gz root@lhdpc:~# /usr/sbin/mysqld -V /usr/sbin/mysqld Ver 8.0.27-0ubuntu0.21.10.1 for Linux on x86_64 ((Ubuntu))
四,查看linux版本:
root@lhdpc:~# cat /etc/os-release PRETTY_NAME="Ubuntu 21.10" NAME="Ubuntu" VERSION_ID="21.10" VERSION="21.10 (Impish Indri)" VERSION_CODENAME=impish ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=impish
相关文章
- [Linux] linux文件系统学习
- Linux(Ubuntu)安装并破解 SecureFX
- Linux 安装 adb环境
- linux下mysql 5.5.38 源码安装笔记
- Linux下安装Tomcat服务器和部署Web应用
- linux(ubuntu 21.10): apt-get安装mysql8.0.27
- linux安装minikube(Ubuntu/deepin)
- Linux Ubuntu 22.04安装后的配置优化:安装gnome-tweaks 及安装gnome-shell
- linux ubuntu 22.04安装后配置优化:调整 Dock Panel 外观 & 启用 Gnome 扩展支持 & 安装gnome tweaks
- linux deepin ubuntu apt安装openjdk-8-jdk
- git-svn 在ubuntu deepin(Linux debian系)下的安装与应用
- linux ubuntu/deepin安装tengine(nginx增强版)2.3.2
- Linux下php安装Redis扩展
- VM之Linux:Linux的Ubuntu中,解决安装后屏幕太小的问题
- Linux安装qt注意事项
- Linux系统之安装PHP环境
- 保姆级教程带你在VMware中安装Linux Debinan操作系统
- Arch Linux 安装博通 BCM4360 驱动(Arch Linux, Ubuntu, Debian, Fedora...)
- VM之Linux:Linux的Ubuntu中,解决安装后屏幕太小的问题
- Linux系统安装最新python详细步骤与问题解决方法【Ubuntu】
- 安装VMware虚拟机操作到Linux联网时显示线缆被拔出解决方法(以太网不可用)
- 02 从头开始atac项目 ubuntu20 install r4.2 Linux系统环境配置 服务器版本的rstudio r install in linux /ubuntu/centos
- ngix入门 Linux系统Ubuntu ngix安装