使用版本:20.04
vim清除所有内容
:%d
切换源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vim /etc/apt/sources.list
sudo apt-get update
配置环境变量
vim ~/.bashrc
最后一行加入export 变量名=变量值
source ~/.bashrc
mysql相关
mysql安装与初始化配置
- 安装:
sudo apt update
sudo apt install mysql-server
初始化配置 sudo mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
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?
# (选择N ,不会进行密码的强校验)
Press y|Y for Yes, any other key for No: N
Please set the password for root here.
New password: ******
Re-enter new password: ******
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.
# (选择N,不删除匿名用户)
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.
# N (选择N,允许root远程连接)
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N
... skipping.
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.
# N (选择N,不删除test数据库)
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.
# Y (选择Y,修改权限立即生效)
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
- 配置远程访问:
找到 bind-address 修改值为 0.0.0.0(如果需要远程访问) sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
重启mysql sudo /etc/init.d/mysql restart
- 设置密码
sudo mysql -uroot -p
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码';
ALTER USER 'root'@'localhost' IDENTIFIED BY '密码' PASSWORD EXPIRE NEVER;
UPDATE user SET host = '%' WHERE user = 'root';
flush privileges;
quit;
mysql卸载
sudo apt-get remove mysql-common
sudo apt-get autoremove --purge mysql-server-8.0
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
sudo rm -rf /etc/mysql/ /var/lib/mysql
sudo apt autoremove
sudo apt autoclean
#sudo apt autoreclean
检查mysql服务状态
systemctl status mysql.service
mysql可视化工具
查看进程
ps -ef|grep mysql
报错相关
- 执行
sudo apt-get update
报错如下:
仓库 “http://ppa.launchpad.net/hzwhuang/ss-qt5/ubuntu focal Release” 没有 Release 文件
解决:
sudo vim /etc/apt/sources.list.d/hzwhuang-ubuntu-ss-qt5-focal.list
注释掉 ppa
那行
sudo apt-get update
- 安装
workbench
时报错如下
//sudo dpkg -i mysql-workbench-community_8.0.20-1ubuntu20.04_amd64.deb
正在选中未选择的软件包 mysql-workbench-community。
(正在读取数据库 ... 系统当前共安装有 202776 个文件和目录。)
准备解压 mysql-workbench-community_8.0.20-1ubuntu20.04_amd64.deb ...
正在解压 mysql-workbench-community (8.0.20-1ubuntu20.04) ...
dpkg: 依赖关系问题使得 mysql-workbench-community 的配置工作不能继续:
mysql-workbench-community 依赖于 libmysqlclient21;然而:
未安装软件包 libmysqlclient21。
mysql-workbench-community 依赖于 libpcrecpp0v5 (>= 7.7);然而:
未安装软件包 libpcrecpp0v5。
mysql-workbench-community 依赖于 libpython2.7 (>= 2.7);然而:
未安装软件包 libpython2.7。
mysql-workbench-community 依赖于 libzip5 (>= 0.10);然而:
未安装软件包 libzip5。
dpkg: 处理软件包 mysql-workbench-community (--install)时出错:
依赖关系问题 - 仍未被配置
正在处理用于 desktop-file-utils (0.24-1ubuntu3) 的触发器 ...
正在处理用于 gnome-menus (3.36.0-1ubuntu1) 的触发器 ...
正在处理用于 mime-support (3.64ubuntu1) 的触发器 ...
正在处理用于 hicolor-icon-theme (0.17-2) 的触发器 ...
正在处理用于 shared-mime-info (1.15-1) 的触发器 ...
在处理时有错误发生:
mysql-workbench-community
解决:
sudo apt-get -f install