【deepin V20】安装Mysql

刚开始用deepin系统,踩了很多坑,其中就包括安装mysql。
写文章前几分钟刚装好。特此记录,希望能帮助到小伙伴们。

一、切换镜像源

地球人都知道,deepin自带的镜像源无法安装mysql,所以第一步换镜像源。

重点:先把必要的软件在「应用商店」里下载了再换源!!!直接换源会导致「应用商店」里(wine)类软件无法下载,比如微信和QQ等。试过把源换回来,还是无法安装此类软件~ 最后被迫重装。下载过(wine)类软件再换没有出现此问题。

  • 编辑文件,注释掉自带的源,替换为阿里源
sudo vim /etc/apt/sources.list
## Generated by deepin-installer
#deb [by-hash=force] https://community-packages.deepin.com/deepin/ apricot main contrib non-free
#deb-src https://community-packages.deepin.com/deepin/ apricot main contrib non-free
deb [by-hash=force] https://mirrors.aliyun.com/deepin/ panda main contrib non-free
  • 更新软件包
sudo apt-get update
sudo apt-get upgrade

二、安装mysql-server、mysql-client

  • 安装mysql
sudo apt-get install mysql-server mysql-client
  • 查看mysql默认用户名和密码
sudo cat /etc/mysql/debian.cnf
[client]
host     = localhost
user     = debian-sys-maint # 账号
password = ynsNEYPcANPFJl1f # 密码
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = ynsNEYPcANPFJl1f
socket   = /var/run/mysqld/mysqld.sock
  • 登录并修改密码
mysql -udebian-sys-maint -pynsNEYPcANPFJl1f
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '你的密码(要包含大小写、数字、特殊字符)';
  • 退出使用root登录即可
mysql> exit
mysql -uroot -pChensong@123

设置字符集:

  • 编辑配置文件,加入以下内容
sudo vi /etc/mysql/conf.d/mysql.cnf
[mysql]
default-character-set=utf8mb4
[mysqld]
character-set-server=utf8mb4
  • 重启,查看字符集
systemctl restart mysql
mysql> show variables like 'character%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

你可能感兴趣的:(deepin,deepin,linux,mysql)