linux安装mysql数据库

1. 下载mysql安装包

在官网下载
https://dev.mysql.com/downloads/mysql/5.7.html#downloads

linux安装mysql数据库_第1张图片
下载

mysql安装包

2.若系统安装了mariadb,请先卸载

(1) 查看mariadb

rpm -qa|grep mariadb

(2) 卸载mariadb

rpm -e --nodeps mariadb-libs-xxx

3.安装mysql

tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm

4.配置mysql

vim /etc/my.cnf

增加

[mysqld]
#skip-grant-tables   //忽略密码验证
lower_case_table_names=1  //忽略大小写
character_set_server=utf8
init_connect='SET NAMES utf8'

5.启动mysql

service mysqld start

6.设置一个密码

mysql
mysql> update mysql.user set authentication_string=password('123456') where user='root';
mysql> flush privileges;

退出重启服务器,再次登录

mysql -uroot -p123456

如果输入命令出错,再重设密码

mysql> set password=password('123456');

如果不行

mysql> ALTER USER USER() IDENTIFIED BY '123456';

若提示太过于简单

mysql> set global validate_password_policy=LOW; 
mysql> set global validate_password_length=6; 

再重试

7.开启远程连接

mysql> update `user` set `host` = '%' where `user` = 'root';   
mysql> flush privileges;

你可能感兴趣的:(linux安装mysql数据库)