操作系统
Oracle
linux Server release 6.3
数据库
MySQL5.6
#添加mysql用户和组
[root@localhost
App]# groupadd mysql
[root@localhost app]# useradd -g mysql mysql
[root@localhost app]#tar zxvf mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz
[root@localhost app]# ls
mysql-5.6.12-linux-glibc2.5-x86_64 oracle
mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz
[root@localhost app]# mv mysql-5.6.12-linux-glibc2.5-x86_64 mysql
[root@localhost app]# chown mysql:mysql mysql
[root@localhost app]# pwd
/app
[root@localhost app]# cd mysql
#初始化mysql库
[root@localhost mysql]# scripts/mysql_install_db --user=mysql --basedir=/app/mysql --datadir=/mydata/
Installing MySQL system tables...2015-05-01 18:31:07 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-05-01 18:31:07 7432 [Note] InnoDB: The InnoDB memory heap is disabled
2015-05-01 18:31:07 7432 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-05-01 18:31:07 7432 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-05-01 18:31:07 7432 [Note] InnoDB: Using Linux native AIO
2015-05-01 18:31:07 7432 [Note] InnoDB: Using CPU crc32 instructions
2015-05-01 18:31:07 7432 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-05-01 18:31:07 7432 [Note] InnoDB: Completed initialization of buffer pool
2015-05-01 18:31:07 7432 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-05-01 18:31:07 7432 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-05-01 18:31:07 7432 [Note] InnoDB: Database physically writes the file full: wait...
2015-05-01 18:31:08 7432 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-05-01 18:31:08 7432 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-05-01 18:31:10 7432 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-05-01 18:31:10 7432 [Warning] InnoDB: New log files created, LSN=45781
2015-05-01 18:31:10 7432 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-05-01 18:31:10 7432 [Note] InnoDB: Doublewrite buffer created
2015-05-01 18:31:10 7432 [Note] InnoDB: 128 rollback segment(s) are active.
2015-05-01 18:31:10 7432 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-05-01 18:31:10 7432 [Note] InnoDB: Foreign key constraint system tables created
2015-05-01 18:31:10 7432 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-05-01 18:31:10 7432 [Note] InnoDB: Tablespace and datafile system tables created.
2015-05-01 18:31:10 7432 [Note] InnoDB: Waiting for purge to start
2015-05-01 18:31:10 7432 [Note] InnoDB: 5.6.12 started; log sequence number 0
2015-05-01 18:31:11 7432 [Note] Binlog end
2015-05-01 18:31:11 7432 [Note] InnoDB: FTS optimize thread exiting.
2015-05-01 18:31:11 7432 [Note] InnoDB: Starting shutdown...
2015-05-01 18:31:12 7432 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2015-05-01 18:31:12 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-05-01 18:31:12 7455 [Note] InnoDB: The InnoDB memory heap is disabled
2015-05-01 18:31:12 7455 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-05-01 18:31:12 7455 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-05-01 18:31:12 7455 [Note] InnoDB: Using Linux native AIO
2015-05-01 18:31:12 7455 [Note] InnoDB: Using CPU crc32 instructions
2015-05-01 18:31:12 7455 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-05-01 18:31:12 7455 [Note] InnoDB: Completed initialization of buffer pool
2015-05-01 18:31:12 7455 [Note] InnoDB: Highest supported file format is Barracuda.
2015-05-01 18:31:12 7455 [Note] InnoDB: 128 rollback segment(s) are active.
2015-05-01 18:31:12 7455 [Note] InnoDB: Waiting for purge to start
2015-05-01 18:31:12 7455 [Note] InnoDB: 5.6.12 started; log sequence number 1625977
2015-05-01 18:31:12 7455 [Note] Binlog end
2015-05-01 18:31:12 7455 [Note] InnoDB: FTS optimize thread exiting.
2015-05-01 18:31:12 7455 [Note] InnoDB: Starting shutdown...
2015-05-01 18:31:14 7455 [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 PASS
word FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/app/mysql/bin/mysqladmin -u root password 'new-password'
/app/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
/app/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 . ; /app/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 with the ./bin/mysqlbug script!
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 /app/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
#把开机脚本传到etc目录下面
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
cp: overwrite `/etc/init.d/mysqld'? y
#添加数据文件和mysql家目录
[root@localhost mysql]# vi /etc/init.d/mysqld
1 #!/bin/sh
2 # Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detro n HB
3 # This file is public domain and comes with NO WARRANTY of any kind
4
5 # MySQL daemon start/stop script.
6
7 # Usually this is put in /etc/init.d (at least on
machines SYSV R4 based
8 # systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql.
9 # When this is done the mysql server will be started when the machine is
10 # started and shut down when the systems goes down.
11
12 # Comments to support chkconfig on RedHat Linux
13 # chkconfig: 2345 64 36
14 # description: A very fast and reliable SQL database engine.
15
16 # Comments to support LSB init script conventions
17 ### BEGIN INIT INFO
18 # Provides: mysql
19 # Required-Start: $local_fs $network $remote_fs
20 # Should-Start: ypbind nscd ldap ntpd xntpd
21 # Required-Stop: $local_fs $network $remote_fs
22 # Default-Start: 2 3 4 5
23 # Default-Stop: 0 1 6
24 # Short-Description: start and stop MySQL
25 # Description: MySQL is a very fast and reliable SQL database engine.
26 ### END INIT INFO
27
28 # If you install MySQL on some other places than /usr/local/mysql, then you
29 # have to do one of the following things for this script to work:
30 #
31 # - Run this script from within the MySQL installation directory
32 # - Create a /etc/my.cnf file with the following information:
33 # [mysqld]
34 # basedir=<path-to-mysql-installation-directory>
35 # - Add the above to any other configuration file (for example ~/.my.ini )
36 # and copy my_print_defaults to /usr/bin
37 # - Add the path to the mysql-installation-directory to the basedir vari able
38 # below.
39 #
40 # If you want to affect other MySQL variables, you should make your chan ges
41 # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
42
43 # If you change base dir, you must also change datadir. These may get
44 # overwritten by settings in the MySQL configuration files.
45
46 basedir=/app/mysql
47 datadir=/mydata
48
49 # Default value, in seconds, afterwhich the script should timeout waitin g
50 # for server start.
51 # Value here is overriden by value in my.cnf.
52 # 0 means don't wait at all
53 # Negative numbers mean to wait indefinitely
54 service_startup_timeout=900
55
56 # Lock directory for RedHat / SuSE.
57 lockdir='/var/lock/subsys'
58 lock_file_path="$lockdir/mysql"
59
60 # The following variables are only set for letting mysql.server find thi ngs.
61
"/etc/rc.d/init.d/mysqld" 390L, 10897C written
#拷贝参数文件到、etc目录
[root@localhost mysql]# cp my.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
[root@localhost mysql]# vi /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.
html[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir =/app/mysql
datadir =/mydata
port =3306
server_id =1
socket=/var/lib/mysql/mysql.sock
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
~
"/etc/my.cnf" 28L, 937C written
#添加开机启动服务
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig --level 2345 mysqld off
[root@localhost mysql]# su - mysql
#重启mysql
[root@localhost mysql]# service mysqld restart
MySQL server PID file could not be found! [FAILED]
Starting MySQL.. [ OK ]
#修改root密码
[root@localhost mysql]# bin/mysqladmin -u root password 'mysql'
-bash-4.1$ mysql -uroot -pmysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.6.12 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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>
声明:本站部分内容及图片来自互联网,转载是出于传递更多信息之目的,内容观点仅代表作者本人,如有任何标注错误或版权侵犯请与我们联系(Email:2595517585@qq.com),我们将及时更正、删除,谢谢。