ubuntu安装mysql_friends多多看书的博客-爱代码爱编程
1. 首先更新数据包
sudo apt update
2. 安装mysql数据库
sudo apt install mysql-server
如果第二部出现错误,缺少安装依赖,更具Ubuntu提示运行安装依赖命令即可
3. 配置安全设置命令
sudo mysql_secure_installation
y|Y for Yes, any other key for No:
是否对密码组件进行配置:输入y
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
强制密码强度
0:低 要求密码长度至少8位
1:中 要求长度至少8位外加什么没什么
2:高 加入了一些什么东西
我这设置的是0
Remove anonymous users?
是否移除匿名用户:输入y
Disallow root login remotely?
是否root用户远程登录:输入y
Remove test database and access to it?
是否移除测试数据库:输入n
Reload privilege tables now?
是否让设置立刻生效:输入y
如果在设置密码时出现 MYSQL设置密码时显示Failed! Error: SET PASSWORD has no significance for user ‘root‘@‘localhost‘ as the authe
退出配置安全命令运行
sudo mysql
设置密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '123456789';
然后再回到重新终端执行配置安全命令
4.登录mysql
sudo mysql -u root -p