Redhat6.5编译安装MySQL5.6.38详解

准备环境

1、系统版本:Redhat6.5

2、jdk版本:1.8

[root@test10 /]# cd tools/
[root@test10 tools]#
[root@test10 tools]# yum -y install numactl* libaio*
[root@test10 tools]# groupadd mysql
[root@test10 tools]# useradd -r -g mysql mysql
[root@test10 tools]# mv mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz /usr/local/
[root@test10 tools]# cd /usr/local/
[root@test10 local]# pwd
/usr/local

[root@test10 local]# tar -zxvf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz
[root@test10 local]# mv mysql-5.6.38-linux-glibc2.12-x86_64 mysql
[root@test10 local]# chown -R mysql:mysql mysql

[root@test10 local]# vi /etc/hosts
192.168.0.10 test10
[root@test10 local]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.10 test10
[root@test10 local]# cd mysql/scripts/
[root@test10 scripts]# ll
total 36
-rwxr-xr-x. 1 mysql mysql 34558 Sep 14 2017 mysql_install_db
[root@test10 scripts]#

[root@test10 scripts]# pwd
/usr/local/mysql/scripts
[root@test10 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Installing MySQL system tables...2021-01-06 15:37:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-01-06 15:37:40 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2021-01-06 15:37:40 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.38) starting as process 10172 ...
2021-01-06 15:37:41 10172 [Note] InnoDB: Using atomics to ref count buffer pool pages
2021-01-06 15:37:41 10172 [Note] InnoDB: The InnoDB memory heap is disabled
2021-01-06 15:37:41 10172 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-01-06 15:37:41 10172 [Note] InnoDB: Memory barrier is not used
2021-01-06 15:37:41 10172 [Note] InnoDB: Compressed tables use zlib 1.2.3
2021-01-06 15:37:41 10172 [Note] InnoDB: Using Linux native AIO
2021-01-06 15:37:41 10172 [Note] InnoDB: Using CPU crc32 instructions
2021-01-06 15:37:41 10172 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2021-01-06 15:37:41 10172 [Note] InnoDB: Completed initialization of buffer pool
2021-01-06 15:37:41 10172 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2021-01-06 15:37:41 10172 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2021-01-06 15:37:41 10172 [Note] InnoDB: Database physically writes the file full: wait...
2021-01-06 15:37:41 10172 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2021-01-06 15:37:41 10172 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2021-01-06 15:37:41 10172 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2021-01-06 15:37:41 10172 [Warning] InnoDB: New log files created, LSN=45781
2021-01-06 15:37:41 10172 [Note] InnoDB: Doublewrite buffer not found: creating new
2021-01-06 15:37:41 10172 [Note] InnoDB: Doublewrite buffer created
2021-01-06 15:37:41 10172 [Note] InnoDB: 128 rollback segment(s) are active.
2021-01-06 15:37:41 10172 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-01-06 15:37:41 10172 [Note] InnoDB: Foreign key constraint system tables created
2021-01-06 15:37:41 10172 [Note] InnoDB: Creating tablespace and datafile system tables.
2021-01-06 15:37:41 10172 [Note] InnoDB: Tablespace and datafile system tables created.
2021-01-06 15:37:41 10172 [Note] InnoDB: Waiting for purge to start
2021-01-06 15:37:41 10172 [Note] InnoDB: 5.6.38 started; log sequence number 0
2021-01-06 15:37:44 10172 [Note] Binlog end
2021-01-06 15:37:44 10172 [Note] InnoDB: FTS optimize thread exiting.
2021-01-06 15:37:44 10172 [Note] InnoDB: Starting shutdown...
2021-01-06 15:37:45 10172 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2021-01-06 15:37:45 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-01-06 15:37:45 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2021-01-06 15:37:45 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.38) starting as process 10194 ...
2021-01-06 15:37:45 10194 [Note] InnoDB: Using atomics to ref count buffer pool pages
2021-01-06 15:37:45 10194 [Note] InnoDB: The InnoDB memory heap is disabled
2021-01-06 15:37:45 10194 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-01-06 15:37:45 10194 [Note] InnoDB: Memory barrier is not used
2021-01-06 15:37:45 10194 [Note] InnoDB: Compressed tables use zlib 1.2.3
2021-01-06 15:37:45 10194 [Note] InnoDB: Using Linux native AIO
2021-01-06 15:37:45 10194 [Note] InnoDB: Using CPU crc32 instructions
2021-01-06 15:37:45 10194 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2021-01-06 15:37:45 10194 [Note] InnoDB: Completed initialization of buffer pool
2021-01-06 15:37:45 10194 [Note] InnoDB: Highest supported file format is Barracuda.
2021-01-06 15:37:45 10194 [Note] InnoDB: 128 rollback segment(s) are active.
2021-01-06 15:37:45 10194 [Note] InnoDB: Waiting for purge to start
2021-01-06 15:37:45 10194 [Note] InnoDB: 5.6.38 started; log sequence number 1625977
2021-01-06 15:37:46 10194 [Note] Binlog end
2021-01-06 15:37:46 10194 [Note] InnoDB: FTS optimize thread exiting.
2021-01-06 15:37:46 10194 [Note] InnoDB: Starting shutdown...
2021-01-06 15:37:47 10194 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

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:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h test10 password 'new-password'

Alternatively you can run:

/usr/local/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 . ; /usr/local/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 /usr/local/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

[root@test10 scripts]#

[root@test10 scripts]# cd ..
[root@test10 mysql]# ll
total 76
drwxr-xr-x. 2 mysql mysql 4096 Aug 5 16:36 bin
-rw-r--r--. 1 mysql mysql 17987 Sep 13 2017 COPYING
drwxr-xr-x. 5 mysql mysql 4096 Aug 5 16:41 data
drwxr-xr-x. 2 mysql mysql 4096 Aug 5 16:36 docs
drwxr-xr-x. 3 mysql mysql 4096 Aug 5 16:36 include
drwxr-xr-x. 3 mysql mysql 4096 Aug 5 16:36 lib
drwxr-xr-x. 4 mysql mysql 4096 Aug 5 16:36 man
-rw-r--r--. 1 root root 943 Aug 5 16:40 my.cnf
-rw-r--r--. 1 root root 943 Aug 5 16:41 my-new.cnf
drwxr-xr-x. 10 mysql mysql 4096 Aug 5 16:36 mysql-test
-rw-r--r--. 1 mysql mysql 2496 Sep 13 2017 README
drwxr-xr-x. 2 mysql mysql 4096 Aug 5 16:36 scripts
drwxr-xr-x. 28 mysql mysql 4096 Aug 5 16:36 share
drwxr-xr-x. 4 mysql mysql 4096 Aug 5 16:36 sql-bench
drwxr-xr-x. 2 mysql mysql 4096 Aug 5 16:36 support-files

[root@test10 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@test10 mysql]# chmod 755 /etc/init.d/mysqld
[root@test10 mysql]# cp support-files/my-default.cnf /etc/my.cnf
cp: overwrite ‘/etc/my.cnf’? yes

[root@test10 mysql]# vi /etc/init.d/mysqld
basedir = /usr/loacl/mysql
datadir = /usr/local/mysql/data

9、启动服务
[root@test10 mysql]# service mysqld restart
Shutting down MySQL.. [ OK ]
/etc/init.d/mysqld: line 264: cd: /usr/loacl/mysql: No such file or directory
Starting MySQLCouldn't find MySQL server (/usr/loacl/mysql/[FAILED]ld_safe)

[root@test10 mysql]# ps -ef|grep mysql
root 3004 1 0 16:57 pts/2 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/test10.pid
mysql 3101 3004 0 16:57 pts/2 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=test10.err --pid-file=/usr/local/mysql/data/test10.pid
root 3130 2329 0 16:59 pts/2 00:00:00 grep mysql
[root@test10 mysql]#

10、链接命令
[root@test10 mysql]# pwd
/usr/local/mysql
[root@test10 mysql]# ./bin/mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.6.38 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> 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> create user 'txytest'@'%' identified by 'txytest123';
Query OK, 0 rows affected (0.10 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'txytest'@'%' IDENTIFIED BY 'txytest123' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges ;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from mysql.user;
+---------+-----------+-------------------------------------------+
| user | host | password |
+---------+-----------+-------------------------------------------+
| root | localhost | |
| root | test10 | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | test10 | |
| txytest | % | *437968540ABB511F0A5CC2BE18839AE31EC2863F |
+---------+-----------+-------------------------------------------+
7 rows in set (0.00 sec)

mysql> quit
Bye

远程连接:

IP:192.168.0.10 端口:3306 MySQL版本:5.6.38

账号:txytest

密码:txytest123

原文地址:https://www.cnblogs.com/zhangkaimin/p/14247685.html