==----------------------------------------------------------------------------------------------------------------------
卷首语:跟上一篇略有不同,但规避了关键部分的报错,可作参考!
LINUX - mysql-5.6.16
1、获取资源
cd /fitness/software/mysql-5.6.16/
wget http://dev.mysql.com/downloads/mysql/mysql-5.6.16.tar.gz # 下载不了,自己后来重下载了资源
2、添加mysql用户,创建mysql目录及数据目录
groupadd mysql
mkdir -pv /fitness/serve/mysql
useradd -r -g mysql -d /fitness/serve/mysql -s /sbin/nologin mysql
chown -R mysql.mysql /fitness/serve/mysql
3、安装cmake依赖
yum install cmake gcc* ncurses-devel -y
Installed:
cmake.x86_64 0:2.8.12.2-2.el7 gcc-aarch64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-alpha-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-arm-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-avr32-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-bfin-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-aarch64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-alpha-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-c++-arm-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-avr32-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-bfin-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-c6x-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-c++-cris-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-frv-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-h8300-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-hppa-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-c++-hppa64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-ia64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-m32r-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-m68k-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-c++-microblaze-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-mips64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-mn10300-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-powerpc64-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-c++-ppc64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-s390x-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-sh-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-sh64-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-c++-sparc64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-tile-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-x86_64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-c++-xtensa-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-c6x-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-cris-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-frv-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-gfortran.x86_64 0:4.8.5-36.el7_6.2
gcc-gnat.x86_64 0:4.8.5-36.el7_6.2 gcc-go.x86_64 0:4.8.5-36.el7_6.2 gcc-h8300-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-hppa-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-hppa64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-ia64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-m32r-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-m68k-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-microblaze-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-mips64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-mn10300-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-objc.x86_64 0:4.8.5-36.el7_6.2
gcc-objc++.x86_64 0:4.8.5-36.el7_6.2 gcc-plugin-devel.x86_64 0:4.8.5-36.el7_6.2 gcc-powerpc64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-ppc64-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-s390x-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-sh-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-sh64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-sparc64-linux-gnu.x86_64 0:4.8.5-16.el7.1
gcc-tile-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-x86_64-linux-gnu.x86_64 0:4.8.5-16.el7.1 gcc-xtensa-linux-gnu.x86_64 0:4.8.5-16.el7.1 gccxml.x86_64 0:0.9.0-0.27.20150423.git3afa8ba.el7
ncurses-devel.x86_64 0:5.9-14.20130511.el7_4
Dependency Installed:
binutils-aarch64-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-alpha-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-arm-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-avr32-linux-gnu.x86_64 0:2.27-9.el7.1
binutils-bfin-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-c6x-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-cris-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-frv-linux-gnu.x86_64 0:2.27-9.el7.1
binutils-h8300-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-hppa-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-hppa64-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-ia64-linux-gnu.x86_64 0:2.27-9.el7.1
binutils-m32r-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-m68k-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-microblaze-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-mips64-linux-gnu.x86_64 0:2.27-9.el7.1
binutils-mn10300-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-powerpc64-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-s390x-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-sh-linux-gnu.x86_64 0:2.27-9.el7.1
binutils-sh64-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-sparc64-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-tile-linux-gnu.x86_64 0:2.27-9.el7.1 binutils-x86_64-linux-gnu.x86_64 0:2.27-9.el7.1
binutils-xtensa-linux-gnu.x86_64 0:2.27-9.el7.1 cross-binutils-common.noarch 0:2.27-9.el7.1 cross-gcc-common.noarch 0:4.8.5-16.el7.1 gmp-devel.x86_64 1:6.0.0-15.el7
libarchive.x86_64 0:3.1.2-10.el7_2 libgfortran.x86_64 0:4.8.5-36.el7_6.2 libgnat.x86_64 0:4.8.5-36.el7_6.2 libgnat-devel.x86_64 0:4.8.5-36.el7_6.2
libgo.x86_64 0:4.8.5-36.el7_6.2 libgo-devel.x86_64 0:4.8.5-36.el7_6.2 libmpc-devel.x86_64 0:1.0.1-3.el7 libobjc.x86_64 0:4.8.5-36.el7_6.2
libquadmath.x86_64 0:4.8.5-36.el7_6.2 libquadmath-devel.x86_64 0:4.8.5-36.el7_6.2 mpfr-devel.x86_64 0:3.1.1-4.el7
Complete!
4、编译安装mysql
cmake -DCMAKE_INSTALL_PREFIX=/fitness/serve/mysql -DDEFAULT_CHARSET=utf8mb4 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/fitness/serve/mysql/data -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DDEFAULT_COLLATION=utf8mb4_general_ci
注意:
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
这两个一定要统一,否则,安装的过程就会报错!会省去很多不必要的麻烦!
make
这个过程有点长,可能得等一会
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o
Linking CXX executable mysql_embedded
[100%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[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: /fitness/serve/mysql/man/man8/mysqld.8
-- Installing: /fitness/serve/mysql/support-files/solaris/postinstall-solaris
5、拷贝mysql的配置文件
cd /fitness/serve/mysql/support-files/
cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld
大概在46/47行,配置如下:
basedir=/fitness/serve/mysql
datadir=/fitness/serve/mysql/data
6、初始化数据库
cd /fitness/serve/mysql/scripts/
./mysql_install_db --user=mysql --basedir=/fitness/serve/mysql/ --datadir=/fitness/serve/mysql/data
[root@iZ8vb2uz59jd5pisp87ljjZ scripts]# ./mysql_install_db --user=mysql --basedir=/fitness/serve/mysql/ --datadir=/fitness/serve/mysql/data
Can't locate Data/Dumper.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./mysql_install_db line 42.
BEGIN failed--compilation aborted at ./mysql_install_db line 42.
报错:Can't locate Data/Dumper.pm in @INC
原因是:缺少 Data-Dumper-2.154.tar.gz这个包,直接下载安装就ok了
wget http://www.cpan.org/modules/by-module/Data/Data-Dumper-2.154.tar.gz
tar xvzf Data-Dumper-2.154.tar.gz
cd Data-Dumper-2.121
perl Makefile.PL 【1】
make
make install
又报错:
[root@iZ8vb2uz59jd5pisp87ljjZ Data-Dumper-2.154]# perl Makefile.PL
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 2.
BEGIN failed--compilation aborted at Makefile.PL line 2.
解决:
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
继续【1】
[root@iZ8vb2uz59jd5pisp87ljjZ Data-Dumper-2.154]# perl Makefile.PL
Checking if your kit is complete...
Looks good
Warning: prerequisite Test::More 0.98 not found.
Writing Makefile for Data::Dumper
[root@iZ8vb2uz59jd5pisp87ljjZ Data-Dumper-2.154]# make && make install
cp Dumper.pm blib/lib/Data/Dumper.pm
/usr/bin/perl /usr/share/perl5/vendor_perl/ExtUtils/xsubpp -typemap /usr/share/perl5/ExtUtils/typemap Dumper.xs > Dumper.xsc && mv Dumper.xsc Dumper.c
gcc -c -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DVERSION=\"2.154\" -DXS_VERSION=\"2.154\" -fPIC "-I/usr/lib64/perl5/CORE" -DUSE_PPPORT_H Dumper.c
Running Mkbootstrap for Data::Dumper ()
chmod 644 Dumper.bs
rm -f blib/arch/auto/Data/Dumper/Dumper.so
gcc -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wl,-z,relro Dumper.o -o blib/arch/auto/Data/Dumper/Dumper.so \
\
chmod 755 blib/arch/auto/Data/Dumper/Dumper.so
cp Dumper.bs blib/arch/auto/Data/Dumper/Dumper.bs
chmod 644 blib/arch/auto/Data/Dumper/Dumper.bs
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/lib64/perl5/auto/Data/Dumper/Dumper.bs
Installing /usr/lib64/perl5/auto/Data/Dumper/Dumper.so
Installing /usr/lib64/perl5/Data/Dumper.pm
Appending installation info to /usr/lib64/perl5/perllocal.pod
真是人生哪有不报错,及时解决欢乐多啊!继续:
cd /fitness/serve/mysql/scripts/
./mysql_install_db --user=mysql --basedir=/fitness/serve/mysql --datadir=/fitness/serve/mysql/data
结果:
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/fitness/serve/mysql/bin/mysqladmin -u root password 'new-password'
/fitness/serve/mysql/bin/mysqladmin -u root -h iZ8vb2uz59jd5pisp87ljjZ password 'new-password'
Alternatively you can run:
/fitness/serve/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /fitness/serve/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /fitness/serve/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
7、把mysql加入系统服务项,并设置开机启动
chkconfig --add mysqld
chkconfig mysqld on
8、可以启动一下
[root@iZ8vb2uz59jd5pisp87ljjZ /]# /etc/init.d/mysqld start
Starting MySQL. [ OK ]
9、登入mysql
/fitness/serve/mysql/bin/mysql
[root@iZ8vb2uz59jd5pisp87ljjZ /]# /fitness/serve/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.16 Source distribution
Copyright (c) 2000, 2014, 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 databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.16 |
+-----------+
1 row in set (0.00 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
10、开启远程登录
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
11、测试连接数据库
注意:如果您是阿里云的ecs服务器上搭建的mysql,需配置安全组,开启3306的端口,具体步骤如下:
【登录阿里云】-》【控制台】-》【ESC服务器】-》看到【ecs服务器列表】-》如果您有多台ecs,随便选择一个,在‘操作栏’,点击【更多】
-》【网络和安全组】-》【安全组配置】-》【配置规则】-》【添加安全组规则】-》端口范围:3306;授权对象:1.1.1.1(你自己的ip);描述:mysql
-》【确定】-》OK 完!
12、mysql启动脚本加入PATH路径
vi /etc/profile
export PATH=/fitness/serve/mysql/bin:/fitness/serve/mysql/lib:$PATH
source /etc/profile #使用环境变量生效
13、启动mysql服务并加入开机自启动
service mysqld start
chkconfig --level 35 mysqld on
[root@iZ8vb2uz59jd5pisp87ljiZ lib]# service mysqld start
Starting MySQL [ OK ]
----------------------------------------------------------------------------------------------------------------------==
Lnmp环境搭建之mysql-5.6.16的安装配置【2】
最新推荐文章于 2021-02-22 03:33:50 发布