MySQL-5.6.30-Linux-glibc2.5-x86_64.tar.gz下载地址:
系统版本:
- [mysql@localhost scripts]$ uname -a
- Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[mysql@localhost scripts]$ uname -a
Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
- [root@localhost mysql]# tar -zxf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
- 修改文件夹为mysql [root@localhost mysql]# mv mysql-5.6.30-linux-glibc2.5-x86_64 mysql
[root@localhost mysql]# tar -zxf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
- [root@localhost mysql]# useradd mysql
[root@localhost mysql]# useradd mysql
- [root@localhost mysql]# echo '123456'|passwd --stdin mysql
[root@localhost mysql]# echo '123456'|passwd --stdin mysql
- [root@localhost mysql]# cd /usr/local
[root@localhost mysql]# cd /usr/local
- [root@localhost local]# chown -R mysql:mysql mysql/
[root@localhost local]# chown -R mysql:mysql mysql/
- [root@localhost local]# su - mysql
[root@localhost local]# su - mysql
- [mysql@localhost ~]$ cd /usr/local/mysql/scripts/
[mysql@localhost ~]$ cd /usr/local/mysql/scripts/
- [mysql@localhost scripts]$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[mysql@localhost scripts]$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
输出信息:
- [mysql@localhost scripts]$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
- Installing MySQL system tables...2016-04-17 07:41:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
- 2016-04-17 07:41:40 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.30) starting as process 3394 ...
- 2016-04-17 07:41:40 3394 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
- 2016-04-17 07:41:40 3394 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
- 2016-04-17 07:41:40 3394 [Note] InnoDB: Using atomics to ref count buffer pool pages
- 2016-04-17 07:41:40 3394 [Note] InnoDB: The InnoDB memory heap is disabled
- 2016-04-17 07:41:40 3394 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
- 2016-04-17 07:41:40 3394 [Note] InnoDB: Memory barrier is not used
- 2016-04-17 07:41:40 3394 [Note] InnoDB: Compressed tables use zlib 1.2.3
- 2016-04-17 07:41:40 3394 [Note] InnoDB: Using Linux native AIO
- 2016-04-17 07:41:40 3394 [Note] InnoDB: Using CPU crc32 instructions
- 2016-04-17 07:41:40 3394 [Note] InnoDB: Initializing buffer pool, size = 128.0M
- 2016-04-17 07:41:40 3394 [Note] InnoDB: Completed initialization of buffer pool
- 2016-04-17 07:41:41 3394 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
- 2016-04-17 07:41:41 3394 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
- 2016-04-17 07:41:41 3394 [Note] InnoDB: Database physically writes the file full: wait...
- 2016-04-17 07:41:41 3394 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
- 2016-04-17 07:41:42 3394 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
- 2016-04-17 07:41:44 3394 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
- 2016-04-17 07:41:44 3394 [Warning] InnoDB: New log files created, LSN=45781
- 2016-04-17 07:41:44 3394 [Note] InnoDB: Doublewrite buffer not found: creating new
- 2016-04-17 07:41:44 3394 [Note] InnoDB: Doublewrite buffer created
- 2016-04-17 07:41:44 3394 [Note] InnoDB: 128 rollback segment(s) are active.
- 2016-04-17 07:41:44 3394 [Warning] InnoDB: Creating foreign key constraint system tables.
- 2016-04-17 07:41:44 3394 [Note] InnoDB: Foreign key constraint system tables created
- 2016-04-17 07:41:44 3394 [Note] InnoDB: Creating tablespace and datafile system tables.
- 2016-04-17 07:41:44 3394 [Note] InnoDB: Tablespace and datafile system tables created.
- 2016-04-17 07:41:44 3394 [Note] InnoDB: Waiting for purge to start
- 2016-04-17 07:41:44 3394 [Note] InnoDB: 5.6.30 started; log sequence number 0
- 2016-04-17 07:41:45 3394 [Note] Binlog end
- 2016-04-17 07:41:45 3394 [Note] InnoDB: FTS optimize thread exiting.
- 2016-04-17 07:41:45 3394 [Note] InnoDB: Starting shutdown...
- 2016-04-17 07:41:46 3394 [Note] InnoDB: Shutdown completed; log sequence number 1625977
- OK
- Filling help tables...2016-04-17 07:41:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
- 2016-04-17 07:41:46 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.30) starting as process 3417 ...
- 2016-04-17 07:41:46 3417 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
- 2016-04-17 07:41:46 3417 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Using atomics to ref count buffer pool pages
- 2016-04-17 07:41:46 3417 [Note] InnoDB: The InnoDB memory heap is disabled
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Memory barrier is not used
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Compressed tables use zlib 1.2.3
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Using Linux native AIO
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Using CPU crc32 instructions
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Initializing buffer pool, size = 128.0M
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Completed initialization of buffer pool
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Highest supported file format is Barracuda.
- 2016-04-17 07:41:46 3417 [Note] InnoDB: 128 rollback segment(s) are active.
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Waiting for purge to start
- 2016-04-17 07:41:46 3417 [Note] InnoDB: 5.6.30 started; log sequence number 1625977
- 2016-04-17 07:41:46 3417 [Note] Binlog end
- 2016-04-17 07:41:46 3417 [Note] InnoDB: FTS optimize thread exiting.
- 2016-04-17 07:41:46 3417 [Note] InnoDB: Starting shutdown...
- 2016-04-17 07:41:48 3417 [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 localhost.localdomain 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
[mysql@localhost scripts]$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Installing MySQL system tables...2016-04-17 07:41:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-17 07:41:40 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.30) starting as process 3394 ...
2016-04-17 07:41:40 3394 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2016-04-17 07:41:40 3394 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2016-04-17 07:41:40 3394 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-04-17 07:41:40 3394 [Note] InnoDB: The InnoDB memory heap is disabled
2016-04-17 07:41:40 3394 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-04-17 07:41:40 3394 [Note] InnoDB: Memory barrier is not used
2016-04-17 07:41:40 3394 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-04-17 07:41:40 3394 [Note] InnoDB: Using Linux native AIO
2016-04-17 07:41:40 3394 [Note] InnoDB: Using CPU crc32 instructions
2016-04-17 07:41:40 3394 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-04-17 07:41:40 3394 [Note] InnoDB: Completed initialization of buffer pool
2016-04-17 07:41:41 3394 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-04-17 07:41:41 3394 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-04-17 07:41:41 3394 [Note] InnoDB: Database physically writes the file full: wait...
2016-04-17 07:41:41 3394 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-04-17 07:41:42 3394 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-04-17 07:41:44 3394 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-04-17 07:41:44 3394 [Warning] InnoDB: New log files created, LSN=45781
2016-04-17 07:41:44 3394 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-04-17 07:41:44 3394 [Note] InnoDB: Doublewrite buffer created
2016-04-17 07:41:44 3394 [Note] InnoDB: 128 rollback segment(s) are active.
2016-04-17 07:41:44 3394 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-04-17 07:41:44 3394 [Note] InnoDB: Foreign key constraint system tables created
2016-04-17 07:41:44 3394 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-04-17 07:41:44 3394 [Note] InnoDB: Tablespace and datafile system tables created.
2016-04-17 07:41:44 3394 [Note] InnoDB: Waiting for purge to start
2016-04-17 07:41:44 3394 [Note] InnoDB: 5.6.30 started; log sequence number 0
2016-04-17 07:41:45 3394 [Note] Binlog end
2016-04-17 07:41:45 3394 [Note] InnoDB: FTS optimize thread exiting.
2016-04-17 07:41:45 3394 [Note] InnoDB: Starting shutdown...
2016-04-17 07:41:46 3394 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2016-04-17 07:41:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-17 07:41:46 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.30) starting as process 3417 ...
2016-04-17 07:41:46 3417 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
2016-04-17 07:41:46 3417 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)
2016-04-17 07:41:46 3417 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-04-17 07:41:46 3417 [Note] InnoDB: The InnoDB memory heap is disabled
2016-04-17 07:41:46 3417 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-04-17 07:41:46 3417 [Note] InnoDB: Memory barrier is not used
2016-04-17 07:41:46 3417 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-04-17 07:41:46 3417 [Note] InnoDB: Using Linux native AIO
2016-04-17 07:41:46 3417 [Note] InnoDB: Using CPU crc32 instructions
2016-04-17 07:41:46 3417 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-04-17 07:41:46 3417 [Note] InnoDB: Completed initialization of buffer pool
2016-04-17 07:41:46 3417 [Note] InnoDB: Highest supported file format is Barracuda.
2016-04-17 07:41:46 3417 [Note] InnoDB: 128 rollback segment(s) are active.
2016-04-17 07:41:46 3417 [Note] InnoDB: Waiting for purge to start
2016-04-17 07:41:46 3417 [Note] InnoDB: 5.6.30 started; log sequence number 1625977
2016-04-17 07:41:46 3417 [Note] Binlog end
2016-04-17 07:41:46 3417 [Note] InnoDB: FTS optimize thread exiting.
2016-04-17 07:41:46 3417 [Note] InnoDB: Starting shutdown...
2016-04-17 07:41:48 3417 [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 localhost.localdomain 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
注:若执行以上最后一个命令出现以下问题:
FATAL ERROR: please install the following Perl modules before executing
./scripts/mysql_install_db:Data::Dumper
解决方法 :安装autoconf库
命令: yum -y install autoconf //此包安装时会安装Data:Dumper模块
安装完成重新执行上述最后一个命令
datadir=/usr/local/mysql/data
通过vim编辑器编辑my.cnf代码如下:
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
socket=/var/lib/mysql/mysql.sock
basedir = /usr/local/mysql
[mysqld]
datadir = /usr/local/mysql/data
skip-name-resolve
#设置3306端口
port = 3306
socket=/var/lib/mysql/mysql.sock
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
lower_case_table_name=1
max_allowed_packet=16M
[safe_mysqld]
err-log=/usr/local/mysql/mysqld.log
pid-file=/usr/local/mysql/mysqld.pid
vi /etc/profile
export PATH=$MYSQL_HOME/bin:$PATH
- [root@localhost mysql]# chkconfig --add mysql
- [root@localhost mysql]# chkconfig mysql on
- 检查mysql服务是否已经生效
[root@localhost mysql]# chkconfig --list mysql
命令输出类似下面的结果:
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
表明mysql服务已经生效,在2、3、4、5运行级别随系统启动而自动启动,以后可以使用systemctl命令控制mysql的启动和停止
- [root@localhost mysql]# service mysql start
- Starting MySQL.. SUCCESS!
[root@localhost mysql]# chkconfig --add mysql
[root@localhost mysql]# chkconfig mysql on
[root@localhost mysql]# service mysql start
Starting MySQL.. SUCCESS!
设置root登录密码:
- /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
登录:
- [mysql@localhost ~]$ mysql -uroot -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 6
- Server version: 5.6.30 MySQL Community Server (GPL)
- Copyright (c) 2000, 2016, 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@localhost ~]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.30 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
- Query OK, 0 rows affected (0.06 sec)
- mysql> FLUSH PRIVILEGES;
- Query OK, 0 rows affected (0.04 sec)
- mysq>
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.06 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.04 sec)
mysql>