概述
1.首先更新本地存储库索引,执行sudo apt update
2.执行安装命令:sudo apt install mysql-server -y,遇到下面的报错
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
执行删除命令:
sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/lib/dpkg/lock
然后继续执行安装命令:sudo apt install mysql-server -y
3.查看mysql服务是否启动:systemctl status mysql.service
pdl@ubuntu:~/Downloads$ systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
Active: active (running) since Fri 2022-07-22 08:09:26 PDT; 7min ago
Main PID: 9595 (mysqld)
Tasks: 28 (limit: 1087)
CGroup: /system.slice/mysql.service
└─9595 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Jul 22 08:09:26 ubuntu systemd[1]: Starting MySQL Community Server...
Jul 22 08:09:26 ubuntu systemd[1]: Started MySQL Community Server.
4.mysql安全设置:sudo mysql_secure_installation
5.登录:sudo mysql -u root -p
6.修改密码:alter user 'root'@'localhost' identified by '12345678';
7.允许root用户远程登录:grant all privileges on *.* to 'root'@'%' identified by '12345678';
8.开通防火墙端口3306:sudo ufw allow 3306
9.修改配置,允许远程连接:
cd /etc/mysql/mysql.conf.d
sudo vim mysqld.cnf
将127.0.0.1注释掉
10.重启服务:sudo systemctl restart mysql
最后
以上就是苹果煎蛋为你收集整理的Ubuntu下安装mysql笔记的全部内容,希望文章能够帮你解决Ubuntu下安装mysql笔记所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复