ubuntu18.04TLS 安装mysql
ubuntu18.04TLS 安装mysql
-
准备环境
ubuntu 18.04 TLS
mysql 5.7.35
-
卸载之前安装的mysql服务
# 删除数据文件 sudo rm /var/lib/mysql/ -R # 删除配置文件 sudo rm /etc/mysql/ -R # 卸载mysql服务端和客户端 sudo apt-get autoremove mysql* --purge sudo apt-get remove apparmor # 检查是否卸载干净,sudo apt-get remove xxx dpkg --list|grep mysql
-
安装
-
安装mysql服务
sudo apt-get install mysql-server
-
初始化服务配置
sudo mysql_secure_installation # 选项 Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD PLUGIN 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 plugin? Press y|Y for Yes, any other key for No: n # 我的选项 Please set the password for root here. New password: xxx Re-enter new password: xxx 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) : y # 我的选项 Success. 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!
-
这个版本会有设置密码不生效的情况
# 查看这个配置文件 sudo cat /etc/mysql/debian.cnf # 配置文件如下所示: root@instance:~# sudo cat /etc/mysql/debian.cnf # Automatically generated for Debian scripts. DO NOT TOUCH! [client] host = localhost user = debian-sys-maint password = nKmBg4nRX7LMxpKz socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = nKmBg4nRX7LMxpKz socket = /var/run/mysqld/mysqld.sock
# 使用用户debian-sys-maint进行登录 mysql -u debian-sys-maint -pnKmBg4nRX7LMxpKz
# 使用mysql数据库 use mysql; # 更新user表中的root的密码 update user set authentication_string=password("你的密码") where user='root'; # 更换客户端支持的加密方式,这里非常重要 update user set plugin="mysql_native_password"; # 重新加载权限表 flush privileges;
-
登录客户端
mysql -u root -p您的密码
-
分类:
服务器
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端