mysql-yum安装

安装源和官方下载包见文章底部

1、下载源、安装mysql,5.6版本
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum install mysql-server -y
2、配置/etc/my.cnf 修改数据和日志目录
vim /etc/my.cnf
[mysqld]
datadir=/data/mysql/data
socket=/var/lib/mysql/mysql.sock
max_connections=1000
#log-bin=mysql-bin     #启用二进制日志-主从使用
#server-id=235           #主从使用
[mysqld_safe]
log-error=/data/mysql/log/mysql.log
pid-file=/var/run/mariadb/mariadb.pid
#创建对应目录文件,修改属主数组
mkdir -p /data/mysql/{data,log}
touch /data/mysql/log/mysqld.log
chown mysql:mysql -R /data/mysql
3、初始化数据库
[root@2dot235 lxt]# su - mysql             #默认安全不允许root直接初始化
-bash-4.2$ mysqld --initialize
-bash-4.2$ exit
[root@2dot235 lxt]# systemctl start mysql
[root@2dot235 lxt]mysqladmin -u root password "new_password"

安装8.0.24版本

wget http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm
rpm -ivh mysql80-community-release-el7-3.noarch.rpm --nodeps --force
yum install mysql-server -y
####第二步同上5.6版本第二步####
####初始化数据库
mysqld --initialize --user=mysql             #默认安全不允许root直接初始化  #记住root初始密码
systemctl start mysqld
mysql -uroot -p                            #输入初始化密码
mysql> alter user 'root'@'localhost' identified by '123456';    #修改root密码
mysql> use mysql;
mysql> update user set host='%' where user='root';              #允许root远程登录
mysql>select user,host from mysql.user;
mysql> flush privileges;

yum源下载地址:http://repo.mysql.com/
官网地址:https://dev.mysql.com/downloads/repo/yum/

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