Deepin系统安装mysql5.7

mysql卸载


sudo apt-get --purge remove mysql-server sudo apt-get --purge remove mysql-client sudo apt-get --purge remove mysql-common ​ 最后再通过下面的命令清理残余 sudo apt-get autoremove sudo apt-get autoclean sudo rm /etc/mysql/ -R sudo rm /var/lib/mysql/ -R

第一次安装请卸载自带mysql

 

Deepin系统源于debian,和ubuntu同为一个linux分支,与centos及redhat不是一个系列,在使用和安装软件方面有很大不同,本文简要记录在Deepin20版本下,安装mysql5.7的过程。

1.在mysql官网下载mysql-server_5.7.34-1debian10_amd64.deb-bundle.tar安装包(当然要根据自己的debian版本选择合适的版本)。

2.拷贝到合适位置(一般:/usr/local),然后解压:

sudo tar -xf mysql-server_5.7.34-1debian10_amd64.deb-bundle.tar

3.安装mysql

sudo dpkg -i mysql-{common,community-client,client,community-server,server}_*.deb

此时会报错:未安装软件包 libmecab2。

4.更新软件源,在/etc/apt/sources.list文件中添加新的软件源:

deb [by-hash=force] https://mirrors.aliyun.com/deepin/ apricot main contrib non-free

千万记得更新系统软件源缓存,使之生效。

sudo apt-get update

5.安装mysql所需的libmecab2

sudo apt-get -y install libmecab2 libjson-perl

然后输入2次密码即可。

安装后,记得使用命令允许root远程访问:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '****' WITH GRANT OPTION;

###分开


FLUSH PRIVILEGES;

备注:如果不能使用右键粘贴,则运行命令:set mouse-=a,即可。

 

接下来修改mysql中字符编码问题:


直接添加mysql的配置文件中编码为utf-8即可:

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

在mysqld节点,添加以下:

character-set-server = utf8

重启mysql服务:

sudo systemctl restart mysql.service

查看当前字符编码:

show variables like 'char%'; 
得到以下结果:
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

修改成功。


至此,mysql 5.7的所有安装配置在deepin中已经完成。

/etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
bind-address = 0.0.0.0
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
#skip-grant-tables
character-set-server = utf8
lower_case_table_names=1

 

 posted on 2023-05-18 13:57  wu小强  阅读(333)  评论(0编辑  收藏  举报