1、检查是否已安装过mariadb,若有便删除(linux系统自带的)
- rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
複製代碼 2、检查是否已安装过mysql,若有便删除(linux系统自带的)
- rpm -e –-nodeps mysql-libs-5.1.52.x86_64
複製代碼 3、检查mysql组和用户是否存在,如无创建:
- cat /etc/group | grep mysql
複製代碼- cat /etc/passwd |grep mysql
複製代碼- useradd -r -g mysql mysql
複製代碼 4、从官网下载mysql安装包,解压后移动到/usr/local/mysql下
- wget https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
複製代碼- tar xvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
複製代碼- mv mysql-5.7.36-linux-glibc2.12-x86_64 mysql
複製代碼 5、在mysql下添加data目录
6、更改mysql目录下所有的目录及文件夹所属组合用户
- chown -R mysql:mysql mysql/
複製代碼 7、编译安装并初始化mysql,记住命令行末尾的密码:
注意:报错1:./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file:报错2:bin/mysqld: error while loading shared libraries: libnuma.so.1: - /home/mysql/bin/mysqld --initialize --user=mysql --datadir=/home/mysql/data --basedir=/home/mysql
複製代碼 2017-08-31T08:50:23.910440Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-08-31T08:50:23.910635Z 0 [ERROR] Can't find error-message file '/usr/local/mysql/--datadir=/usr/local/mysql/data/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' con figuration directive.2017-08-31T08:50:24.709286Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-08-31T08:50:24.767540Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-08-31T08:50:24.892629Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6e083b8f-8e29-11e7-88b1- 005056b427be.2017-08-31T08:50:24.895674Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-08-31T08:50:24.896645Z 1 [Note] A temporary password is generated for root@localhost: gFamcspKm2+u
注意:修改下
/home/mysql/support-files/mysql.server在里面修改安装路径和数据路径位置
8、启动mysql服务 - /home/mysql/support-files/mysql.server start
複製代碼 9、做个软连接,重启服务- ln -s /home/mysql/support-files/mysql.server /etc/init.d/mysql
複製代碼 重启mysql10、做个软链接,将安装目录下的mysql 放在/usr/bin 目录下 - ln -s /home/mysql/bin/mysql /usr/bin
複製代碼
11、登录msyql,输入密码(密码为步骤7初始化生成的密码)
Enter password:
12、修改密码并开放远程
- alter user 'root'@'localhost' identified by '123456';
複製代碼- update user set user.Host='%' where user.User='root';
複製代碼
13、编辑my.cnf,添加配置文件,配置内容为 - [mysqld]port = 3306sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
複製代碼 赋予可执行权限- chmod +x /etc/init.d/mysqld
複製代碼 添加服务 |