1 安装 Apt Repository
地址MySQL :: Download MySQL APT Repository
sudo dpkg -i mysql-apt-config_0.8.30-1_all.deb
- #安装mysql 8.4 lts
- sudo apt update
- sudo apt-get install mysql-server
#修改mysql root密码策略
2 查看版本
- test@test:~$ mysqld --version
- /usr/sbin/mysqld Ver 8.4.0 for Linux on x86_64 (MySQL Community Server - GPL)
3 启动服务
- #启动
- sudo systemctl start mysql
- #开机启动
- sudo systemctl enable mysql
- #查看服务状态
- sudo systemctl status mysql
- #查看端口运行
- test@test:~$ sudo netstat -tnupl| grep mysql
- tcp6 0 0 :::3306 :::* LISTEN 9225/mysqld
- tcp6 0 0 :::33060 :::* LISTEN 9225/mysqld
4 修改mysql root 密码
- #默认密码为空
- sudo mysql -uroot -p
- ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';
- flush privileges;
5 修改 配置文件
- sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
- bind-address = 0.0.0.0
- #重新启动
- sudo systemctl restart mysql