debian10安装mariaDB或mysql5.7
Overview
MariaDB 10.3
MariaDB Server版本: 10.3.31
安装:
1# 安装mariadb
2sudo apt-get install mariadb-server
3
4service mariadb status
5
6# 安装完毕,默认root密码为空
7sudo mysql -u root
8
9# 设置root密码为123456,按提示操作即可
10sudo mysql_secure_installation
11
12# 本地登陆
13sudo mysql -u root -p
14
15# 授权root远程登陆
16GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YOUR_ROOT_PASSWORD_HERE' WITH GRANT OPTION;
17
18# 修改配置允许远程访问
19sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
20
21修改项: bind-address = 0.0.0.0
22
23# 重启服务
24sudo systemctl restart mariadb.service
卸载:
1sudo systemctl stop mariadb.service
2
3sudo apt-get remove --purge mariadb-server mariadb-client mariadb-common
4
5sudo rm -rf /etc/mysql /var/lib/mysql
Mysql 5.7
1sudo apt-get update
2wget -c https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb
3# 选择5.7, enable,enable,ok
4sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
5# 安装,界面中设置root密码
6sudo apt-get update
7sudo apt-get install mysql-server
8
9# 自动启动
10sudo systemctl start mysql
11sudo systemctl enable mysql
12
13sudo systemctl status mysql
14
15# 本地登陆
16sudo mysql -u root -p
17
18# 授权root远程登陆
19GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YOUR_ROOT_PASSWORD_HERE' WITH GRANT OPTION;
20
21# 修改配置允许远程访问
22sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
23修改项: bind-address = 0.0.0.0
24
25# 重启服务
26sudo systemctl restart mysql
卸载:
1sudo systemctl stop mysql
2sudo apt-get remove mysql-server
3sudo apt-get autoremove
4dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P