centos7.3 中mysql5.7源码安装

一、下载安装mysql5.7

        1.下载:

            cd /usr/local/src

            wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz

        2.解压:

                tar  zxvf  mysql-5.7.12-linux-glibc2.5-x86_64.tar

                mv  mysql-5.7.12-linux-glibc2.5-x86_64 /usr/local/mysql

        3.安装:

           3.1.安装之前删除之前的安装信息,如: /etc/my.cnf , /etc/init.d/mysqld等

           3.2. cd /usr/local/mysql

           3.3.新建mysql用户组: groupadd mysql

           3.4.新建mysql用户: useradd -g mysql mysql

           3.5.MySQL依赖于libaio 库。如果此库未在本地安装,则数据目录初始化和后续服务器启动步骤将失败。 

                安装:yum install libaio

           3.6.把mysql目录权限设为mysql用户

                chown mysql:mysql /usr/local/mysql

           .配置环境变量

            vim /etc/profile

            path后面添加/usr/local/mysql/bin保存退出

            source /etc/profile 环境生效

           3.7

                1.shell> bin/mysqld --initialize --user=mysql 启动

                2.shell> bin/mysql_ssl_rsa_setup          

                3.shell> bin/mysqld_safe --user=mysql &  用户初次登陆需要停止mysql执行此语句

                4.shell> cp support-files/mysql.server /etc/init.d/mysql.server  启动文件

5.修改/etc/my.cnf配置文件,初次登陆设置免密登陆:在my.cnf中新增一行skip-grant-tables=1

                6.登陆mysql后修改mysql.user表中的root密码:

                7.update user set authentication_string= password("123456") where user= "root";

                    更新权限:FLUSH PRIVILEGES;

                8.屏蔽my.cnf 中的skip-grant-tables:

                9.重启mysql: service mysql.server restart

                10.登陆: mysql -uroot -p123456

你可能感兴趣的:(mysql)