mysql 57版本安装
Posted 负重前行岁月静好
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 57版本安装相关的知识,希望对你有一定的参考价值。
1、下载tar包,这里使用wget从官网下载
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
2、将mysql安装到/usr/local/mysql下
# 解压
tar -xvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
# 移动
mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/
# 重命名
mv /usr/local/mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/mysql
3、新建data目录
mkdir /usr/local/mysql/data
4、新建mysql用户、mysql用户组
# mysql用户组
groupadd mysql
# mysql用户
useradd mysql -g mysql
5、将/usr/local/mysql的所有者及所属组改为mysql
chown -R mysql.mysql /usr/local/mysql
6、配置
/usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
出现错误执行:
/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize
错误是如下:
/usr/local/mysql/bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
执行:
yum -y install numactl
# 完成后继续安装
/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize
[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
socket=/tmp/mysql.sock
user=mysql
port=3306
character-set-server=utf8
# 取消密码验证
skip-grant-tables
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# skip-grant-tables
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
7、开启服务
# 将mysql加入服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
# 开机自启
chkconfig mysql on
# 开启
service mysql start
#查看初始密码
命令:cat /root/.mysql_secret
#登录
命令:bin/mysql -uroot -p
或者起别名:
alias mysql=‘/usr/local/mysql/bin/mysql‘
vim ~/.bashrc
alias mysql=‘/usr/local/mysql/bin/mysql‘
source ~/.bashrc
登录:mysql -u root -p
8、允许远程连接
mysql -u root -p
>>use mysql;
>>update user set host=‘%‘ where user = ‘root‘;
>>flush privileges;
>>eixt;
以上是关于mysql 57版本安装的主要内容,如果未能解决你的问题,请参考以下文章