CentOS6.9源码安装mysql5.7.10
1、 源码安装:
环境:centos6.9
软件:mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
2、先更新下系统
yum update -y
3、 新建用户:
[root@ruimysql yum.repos.d]# groupadd -g 1000 mysql
[root@ruimysql yum.repos.d]# useradd -u 1000 -g mysql mysql
[root@ruimysql yum.repos.d]# echo mysql | passwd mysql --stdin
4、 更改用户 mysql 的密码 。
passwd: 所有的身份验证令牌已经成功更新。
[root@ruimysql yum.repos.d]#
5、 创建mysql的数据目录
[root@ruimysql ~]# mkdir /mysqldata
[root@ruimysql ~]# chown -R mysql:mysql /mysqldata
[root@ruimysql ~]# chmod -R 775 /mysqldata
[root@ruimysql ~]#
6、 下载包到系统:使用的版本为:
mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
7、 解压:
tar -zxvf mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
8、 将解压出来的包,复制/移动 到/usr/local 下 并改名为:mysql
mv mysql-5.7.10-linux-glibc2.5-x86_64 /usr/local/mysql
[root@ruimysql ~]# cd /usr/local/mysql/
[root@ruimysql mysql]# ll
总用量 160
drwxr-xr-x. 2 7161 wheel 4096 11月 30 2015 bin
-rw-r--r--. 1 7161 wheel 17987 11月 30 2015 COPYING
drwxr-xr-x. 2 7161 wheel 4096 11月 30 2015 docs
drwxr-xr-x. 3 7161 wheel 4096 11月 30 2015 include
-rw-r--r--. 1 7161 wheel 108090 11月 30 2015 INSTALL-BINARY
drwxr-xr-x. 5 7161 wheel 4096 11月 30 2015 lib
drwxr-xr-x. 4 7161 wheel 4096 11月 30 2015 man
-rw-r--r--. 1 7161 wheel 2478 11月 30 2015 README
drwxr-xr-x. 28 7161 wheel 4096 11月 30 2015 share
drwxr-xr-x. 2 7161 wheel 4096 11月 30 2015 support-files
[root@ruimysql mysql]#
9、 进入程序bin下
[root@ruimysql bin]# cd /usr/local/mysql/bin/
[root@ruimysql bin]# ./mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mysqldata/
# --initialize-insecure 生成密码
10、 配置环境变量
[root@ruimysql bin]# vi /etc/profile
11、 在文件末尾加上:
export PATH=$PATH:/usr/local/mysql/bin
:wq保存退出
#使其立即生效
source /etc/profile
12、 将mysql做成系统服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
13、 设置 配置文件 /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir=/mysqldata
socket=/tmp/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
#端口
port = 3306
#表区分大小写
lower_case_table_names=1
character_set_server=utf8
init_connect='SET NAMES utf8'
#server_id=100
#log-bin= /mysqldata/mysql-bin
#不记录mysql的更新
#binlog-ignore-db = mysql
#日志保留7天
expire_logs_days = 7
#最大连接数
max_connections=1500
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld.pid
#记录查询慢的sql语句
long_query_time = 1
slow_query_log = ON
slow_query_log_file = /mysqldata/tmp/slow-query.log
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
default-character-set=utf8
14、 启动服务:
[root@ruimysql ~]# service mysqld start
Starting MySQL. [确定]
[root@ruimysql ~]#
15、登录mysql
[root@ruimysql ~]#mysql -uroot
#由于密码 直接进了。
[root@ruimysql ~]#mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
修改root空密码 设置密码为123456 且允许root远程登录
mysql> use mysql
mysql> update user set authentication_string=password('123456'), password_expired='N' where user="root";
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
到此 mysql就安装完成了。
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。
文章标题:CentOS6.9源码安装mysql5.7.10
本文作者:wangzhirui
发布时间:2019-09-03, 14:42:43
最后更新:2025-02-27, 02:03:57
原始链接:https://wangzhirui.com/2019/09/03/CentOS6-9源码安装mysql5-7-10/转载请保留原文链接及作者。