linux编译安装mysql5.7
发布时间:2020-12-14 01:09:48 所属栏目:Linux 来源:网络整理
导读:一、下载源码包 ? mkdir /usr/local/src/mysql- 5.7 . 26 - srccd /usr/local/src/mysql- 5.7 . 26 - srcwget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26.tar.gz 二、添加mysql用户和组 [[email?protected] ~ ]# groupadd mysql[[email?pr
一、下载源码包? mkdir /usr/local/src/mysql-5.7.26-src cd /usr/local/src/mysql-5.7.26-src wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26.tar.gz 二、添加mysql用户和组[[email?protected] ~]# groupadd mysql [[email?protected] ~]# id myql id: myql: no such user [[email?protected] ~]# useradd -d /home/myql -g mysql -m mysql [[email?protected] ~]# id mysql uid=1000(mysql) gid=1000(mysql) 组=1000(mysql) [[email?protected] ~]# passwd mysql 更改用户 mysql 的密码 。 新的 密码: 重新输入新的 密码: passwd:所有的身份验证令牌已经成功更新。 三、新建相关目录,并赋权限给mysql用户[[email?protected] home]# mkdir /home/mysql-5.7.26 [[email?protected] home]# mkdir /home/mysql-5.7.26/data [[email?protected] home]# mkdir -p /home/mysql-5.7.26/log/iblog [[email?protected] home]# mkdir -p /home/mysql-5.7.26/log/binlog [[email?protected] home]# mkdir -p /home/mysql-5.7.26/run [[email?protected] home]# mkdir -p /home/mysql-5.7.26/tmp ? [[email?protected] home]# chown -R mysql:mysql /home/mysql-5.7.26/ [[email?protected] home]# ll 总用量 0 drwxr-xr-x 6 mysql mysql 51 5月 3 16:25 mysql-5.7.26 [[email?protected] home]# cd mysql-5.7.26/ [[email?protected] mysql-5.7.26]# ll 总用量 0 drwxr-xr-x 2 mysql mysql 6 5月 3 16:24 data drwxr-xr-x 4 mysql mysql 33 5月 3 16:25 log drwxr-xr-x 2 mysql mysql 6 5月 3 16:25 run drwxr-xr-x 2 mysql mysql 6 5月 3 16:25 tmp [[email?protected] mysql-5.7.26]# chmod -R 755 /home/mysql-5.7.26/ [[email?protected] mysql-5.7.26]# ll 总用量 0 drwxr-xr-x 2 mysql mysql 6 5月 3 16:24 data drwxr-xr-x 4 mysql mysql 33 5月 3 16:25 log drwxr-xr-x 2 mysql mysql 6 5月 3 16:25 run drwxr-xr-x 2 mysql mysql 6 5月 3 16:25 tmp 四、解压源码包?cd /usr/local/src/mysql-5.7.26-src tar -zxvf mysql-5.7.26.tar.gz 五、安装相关依赖包yum install cmake gcc gcc-c++ ncurses-devel bison zlib libxml openssl automake autoconf make libtool bison-devel libaio-devel 六、安装boostcd /usr/local wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz tar -zxvf boost_1_59_0.tar.gz 七、编译安装cmake -DCMAKE_INSTALL_PREFIX=/home/mysql-5.7.26 #安装目录 -DINSTALL_DATADIR=/home/mysql-5.7.26/data #数据目录 -DDEFAULT_CHARSET=utf8 #默认编码 make
最后出现: [100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o Linking CXX executable my_safe_process [100%] Built target my_safe_process 编译成功,再执行 make install 最后出现: -- Installing: /home/mysql-5.7.26/./COPYING-test -- Installing: /home/mysql-5.7.26/./README-test -- Up-to-date: /home/mysql-5.7.26/mysql-test/mtr -- Up-to-date: /home/mysql-5.7.26/mysql-test/mysql-test-run -- Installing: /home/mysql-5.7.26/mysql-test/lib/My/SafeProcess/my_safe_process -- Up-to-date: /home/mysql-5.7.26/mysql-test/lib/My/SafeProcess/my_safe_process -- Installing: /home/mysql-5.7.26/mysql-test/lib/My/SafeProcess/Base.pm -- Installing: /home/mysql-5.7.26/support-files/mysqld_multi.server -- Installing: /home/mysql-5.7.26/support-files/mysql-log-rotate -- Installing: /home/mysql-5.7.26/support-files/magic -- Installing: /home/mysql-5.7.26/share/aclocal/mysql.m4 -- Installing: /home/mysql-5.7.26/support-files/mysql.server 进入/home/mysql-5.7.26/目录 [[email?protected] mysql-5.7.26]# ll 总用量 64 drwxr-xr-x 2 root root 4096 5月 15 09:08 bin -rw-r--r-- 1 root root 17987 4月 13 21:32 COPYING -rw-r--r-- 1 root root 17987 4月 13 21:32 COPYING-test drwxr-xr-x 2 mysql mysql 6 5月 3 16:24 data drwxr-xr-x 2 root root 55 5月 15 09:08 docs drwxr-xr-x 3 root root 4096 5月 15 09:08 include drwxr-xr-x 4 root root 192 5月 15 09:08 lib drwxr-xr-x 4 mysql mysql 33 5月 3 16:25 log drwxr-xr-x 4 root root 30 5月 15 09:08 man drwxr-xr-x 10 root root 4096 5月 15 09:08 mysql-test -rw-r--r-- 1 root root 2478 4月 13 21:32 README -rw-r--r-- 1 root root 2478 4月 13 21:32 README-test drwxr-xr-x 2 mysql mysql 6 5月 3 16:25 run drwxr-xr-x 28 root root 4096 5月 15 09:08 share drwxr-xr-x 2 root root 90 5月 15 09:08 support-files drwxr-xr-x 2 mysql mysql 6 5月 3 16:25 tmp 安装成功 八、编写配置文件my.cnf?mkdir /etc/mysql cd /etc/mysql vim my.cnf [mysqld] basedir=/home/mysql-5.7.26 datadir=/home/mysql-5.7.26/data socket=/home/mysql-5.7.26/mysql.sock user=mysql symbolic-links=0 [mysqld_safe] log-error=/home/mysql-5.7.26/log/mysqld.log pid-file=/home/mysql-5.7.26/run/mysqld.pid ? 九、初始化系统数据库[[email?protected] bin]# ./mysqld --initialize --user=mysql --basedir=/home/mysql-5.7.26/ --datadir=/home/mysql-5.7.26/data/ 2019-05-15T06:29:58.880090Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-05-15T06:30:00.176430Z 0 [Warning] InnoDB: New log files created,LSN=45790 2019-05-15T06:30:00.525258Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2019-05-15T06:30:00.673537Z 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: ddbee8c3-76da-11e9-9174-90b11c15be09. 2019-05-15T06:30:00.693221Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened. 2019-05-15T06:30:01.209547Z 0 [Warning] CA certificate ca.pem is self signed. 2019-05-15T06:30:01.257442Z 1 [Note] A temporary password is generated for [email?protected]: O3CaqsqoDy+V 这里显示了第一次登陆时的临时密码,需要记下来 十、启动[[email?protected] bin]# touch /home/mysql-5.7.26/log/mysqld.log [[email?protected] bin]# chown -R mysql:mysql /home/mysql-5.7.26/log/mysqld.log [[email?protected] bin]# ./mysqld_safe --defaults-file=/etc/mysql/my.cnf --user=mysql 2019-05-15T06:33:33.794898Z mysqld_safe Logging to ‘/home/mysql-5.7.26/log/mysqld.log‘. 2019-05-15T06:33:33.826283Z mysqld_safe Starting mysqld daemon with databases from /home/mysql-5.7.26/data ?十一、添加MySQL服务?cp /home/mysql-5.7.26/support-files/mysql.server /etc/init.d/mysqld 十二、启动服务[[email?protected] bin]# service mysqld start
Starting MySQL. SUCCESS!
十三、添加mysql的环境变量vim /etc/profile 最后一行添加 export PATH=/home/mysql-5.7.26/bin:$PATH 十四、连接mysql?先查看mysqld.log日志,查找初始密码,初始密码是在第一次运行初始化数据库时由系统生成的 [[email?protected] data]# cat /home/mysql-5.7.26/log/mysqld.log |grep password 2019-05-15T03:34:45.137254Z 1 [Note] A temporary password is generated for [email?protected]: 1ws;,dEy?kM# 登录 [[email?protected] bin]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 4 Server version: 5.7.26 Copyright (c) 2000,2019,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> 登录成功,此时执行任何命令,提示 mysql> show databases; ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. 需要首先修改密码 ? mysql> set PASSWORD=PASSWORD(‘xxxxxxxx‘); Query OK,0 rows affected,1 warning (0.01 sec) mysql> alter user ‘root‘@‘localhost‘ PASSWORD EXPIRE NEVER; Query OK,0 rows affected (0.00 sec) mysql> flush privileges; Query OK,0 rows affected (0.00 sec) 退出,重新登录 [[email?protected] log]# /home/mysql-5.7.26/bin/mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 3 Server version: 5.7.26 Source distribution Copyright (c) 2000,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> show database; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec ?可以执行命令了 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |