Feng’ Blog

Centos7.0 安装MySQL5.7
检查库文件是否存在,如有删除。rpm -qa | grep mysqlrpm -e mysql-libs-5.1....
扫描右侧二维码阅读全文
28
2017/11

Centos7.0 安装MySQL5.7

检查库文件是否存在,如有删除。

rpm -qa | grep mysql
rpm -e mysql-libs-5.1.52.x86_64 --nodeps
下载MySQL压缩版
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
mysql1.png
添加用户及用户组

检查mysql用户及用户组是否存在

cat /etc/group | grep mysql
cat /etc/passwd | grep mysql

创建mysql用户及用户组

groupadd mysql
useradd -r -g mysql mysql

授权

cd /usr/local
chown -R mysql:mysql mysql/

mysql3.png

在这里可能会报错

error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
解决方法是安装numactl即可
yum search libnuma #查找libnuma 
==================================================================== N/S matched: libnuma =====================================================================
numactl-libs.i686 : libnuma libraries
numactl-libs.x86_64 : libnuma libraries

yum install numactl-libs
# 创建执行程序软连接
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
 
# 拷贝文件到开机启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --list mysqld # 如果不存在则执行下面命令,存在则不执行下面命令
chkconfig --add mysqld
配置my.cnf

vi /etc/my.cnf
 
[mysqld]
datadir=/usr/local/mysql/data
user=mysql
character-set-server=utf8
collation-server=utf8_general_ci
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0


#启动mysql
./support-files/mysql.server start

初始化密码:

mysql -u root -h 127.0.0.1 -p
# 这里的密码是刚才初始化时生成的随机密码
 
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
flush privileges;

安装完成:
mysql5.png
常用的mysql命令:

# 开启服务
service mysqld start
# 关闭服务
service mysqld stop
# 重启服务
service mysqld restart

# 给予任何主机用root账户访问数据的权限 (为安全起见,不建议将root用户远程访问)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION  
FLUSH PRIVILEGES     #刷新
Last modification:January 8th, 2019 at 06:39 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment