Linux下mysql安装及配置

蓝咒 提交于 2020-12-15 08:41:45

二进制方式安装mysql

下载地址

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-server5.7.20-1ubuntu14.04amd64.deb-bundle.tar

tar -xvf mysql-server_5.7.20-1ubuntu14.04_amd64.deb-bundle.tar
sudo apt-get install libaio1 libmecab2 openssh-client
sudo dpkg -i mysql-{common,community-client,client,community-server,server}_5.7.20-1ubuntu14.04_amd64.deb

配置远程访问

sudo vi /etc/mysql/my.cnf 查找到bind-address,

将 bind-address=127.0.0.1 修改为 bind-address = 0.0.0.0 ,可以允许任何IP来访问MySQL服务。

配置登录权限

mysql> grant all privileges on *.* to root@"%" identified by "root" with grant option;

*.*表示[库名].[表名]。 %表示可以任意地址访问,可以换成localhost或具体IP地址,以限制连接的地址

配置不区分大小写

修改配置文件:sudo vi /etc/mysql/my.cnf 在[mysqld]节点下,加入一行: lower_case_table_names=1

设置MySQL字符集,设为utf8mb4,支持emoji

修改配置文件:

sudo vi /etc/mysql/my.cnf

在[mysqld]在下方添加以下代码

[mysqld]

init_connect='SET collation_connection = utf8mb4_unicode_ci'

init_connect='SET NAMES utf8mb4'

character-set-server=utf8mb4

collation-server=utf8mb4_unicode_ci

skip-character-set-client-handshake

使配置生效

第一种方式 mysql> flush privileges;

第二种方式,重启mysql sudo service mysql restart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!