linux-mysql安装

检索相关信息

yum search libaio

安装依赖包

yum install libaio

(检查 MySQL 是否已安装 yum list installed | grep mysql
如果有,就先全部卸载,命令如下: yum -y remove mysql-libs.x86_64)

下载mysql的rpm安装包

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
如果提示-bash: wget: 未找到命令,请先执行 yum install wget 安装 wget

添加 MySQL Yum Repository 到你的系统 repository 列表中,执行

yum localinstall mysql-community-release-el7-5.noarch.rpm

验证下是否添加成功

yum repolist enabled | grep "mysql.-community."

查看 MySQL 版本,执行

yum repolist all | grep mysql

[可选择] 修改mysql版本

vi /etc/yum.repos.d/mysql-community.repo

通过 Yum 来安装 MySQL

yum install mysql-community-server

whereis mysql //查看安装路径

systemctl start mysqld //启动

第一种方法:

/var/log/mysqld.log 文件中查看初始密码 A temporary password

然后登录

mysql -uroot -p

修改密码

mysql> set global validate_password_length=6;
mysql> set global validate_password_policy=0;
mysql> set password = password('Aa123456');
mysql> select host,user,authentication_string from mysql.user;
mysql> grant all privileges on . to 'root'@'%' identified by 'Aa123456' with grant option;
mysql> select host,user,authentication_string from mysql.user;
mysql> flush privileges;

然后阿里云控制台 开启3306端口权限 外部可以直接访问

第二种方法:

vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables

重启mysql

service mysqld restart

修改密码

mysql> set global validate_password_length=6;
mysql> set global validate_password_policy=0;
mysql> set password = password('Aa123456');
mysql> select host,user,authentication_string from mysql.user;
mysql> grant all privileges on . to 'root'@'%' identified by 'Aa123456' with grant option;
mysql> flush privileges;

你可能感兴趣的:(linux-mysql安装)