1.安装
sudo apt install mysql-server
2.设置密码
# 执行命令, 使用debian.cnf文件中系统默认分配的用户名和密码,然后可以对数据库进行操作
sudo vim /etc/mysql/debian.cnf
# 使用用户名为:debian-sys-maint 连接到MySQL数据库,输入debian.cnf文件对应的密码
mysql -u debian-sys-maint -p
# new_password:填写你要修改成的密码
update mysql.user set authentication_string=password('new_password') where user='root' and Host ='localhost';
use mysql;
update user set plugin="mysql_native_password";
flush privileges;
quit;
3.重启
sudo service mysql restart
4.登录
mysql -u root -p
5.删除
sudo apt-get autoremove --purge mysql-server-5.7
sudo apt remove mysql-common
sudo rm -rf /etc/mysql/ /var/lib/mysql #清楚相关配置
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P #清楚残留数据
sudo apt autoremove
sudo apt autoclean
参考文章:https://blog.csdn.net/qq_24395351/article/details/80912628 https://www.cnblogs.com/hupeng1234/p/7003543.html https://www.linuxidc.com/Linux/2017-05/143864.htm
6.使用客户端远程连接Ubuntu操作系统
- 使用命令 ps -e | grep ssh 查看是否安装了 openssh-server 服务
- 安装 openssh-server 服务,使用命令 ssh -p 22 远程用户名@远程IP
7.创建utf8编码的数据库
create database db_name charset utf8;
8.使用mysqldump导出 *.sql 文件:
mysqldump -uroot -p123123 --no-create-info --databases db --tables table_name >~/Desktop/sqlfile/file_table_name.sql
9. 查看数据库编码格式:
show variables like 'character_set_database';