mysql 安装分三步走
一、数据文件的目录放在/data/mysql
二、软件放在/usr/local/
三、配置文件/etc/ --mysql的配置文件必须是‘.cnf’结尾
单实例安装用 my.cnf这个配置文件
上传软件
[root@oracle opt]# mkdir -p /data/mysql
[root@oracle opt]# tar -xf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz -C /usr/local/
cd /usr/local/
[root@oracle local]# mv mysql-5.6.16-linux-glibc2.5-x86_64/ mysql
创建用户mysql
useradd mysql
授权
[root@oracle local]# chown mysql:mysql -R mysql
[root@oracle local]# chown mysql:mysql -R /data/mysql
[root@oracle local]# cd mysql/
[root@oracle mysql]# ll
total 156
drwxr-xr-x 2 mysql mysql 4096 Mar 28 17:10 bin
-rw-r--r-- 1 mysql mysql 17987 Jan 14 2014 COPYING
drwxr-xr-x 3 mysql mysql 4096 Mar 28 17:09 data
drwxr-xr-x 2 mysql mysql 4096 Mar 28 17:10 docs
drwxr-xr-x 3 mysql mysql 4096 Mar 28 17:10 include
-rw-r--r-- 1 mysql mysql 88109 Jan 14 2014 INSTALL-BINARY
drwxr-xr-x 3 mysql mysql 4096 Mar 28 17:10 lib
drwxr-xr-x 4 mysql mysql 4096 Mar 28 17:10 man
drwxr-xr-x 10 mysql mysql 4096 Mar 28 17:10 mysql-test
-rw-r--r-- 1 mysql mysql 2496 Jan 14 2014 README
drwxr-xr-x 2 mysql mysql 4096 Mar 28 17:10 scripts
drwxr-xr-x 28 mysql mysql 4096 Mar 28 17:10 share
drwxr-xr-x 4 mysql mysql 4096 Mar 28 17:10 sql-bench
drwxr-xr-x 3 mysql mysql 4096 Mar 28 17:10 support-files
[root@oracle mysql]# cd scripts/
[root@oracle scripts]# ./mysql_install_db --help
Usage: ./mysql_install_db [OPTIONS]
--basedir=path The path to the MySQL installation directory.
--builddir=path If using --srcdir with out-of-directory builds, you
will need to set this to the location of the build
directory where built files reside.
--cross-bootstrap For internal use. Used when building the MySQL system
tables on a different host than the target.
--datadir=path The path to the MySQL data directory.
If missing, the directory will be created, but its
parent directory must already exist and be writable.
--defaults-extra-file=name
Read this file after the global files are read.
--defaults-file=name Only read default options from the given file name.
--force Causes mysql_install_db to run even if DNS does not
work. In that case, grant table entries that normally
use hostnames will use IP addresses.
--help Display this help and exit.
--ldata=path The path to the MySQL data directory. Same as --datadir.
--no-defaults Don't read default options from any option file.
--random-passwords Create and set a random password for all root accounts
and set the "password expired" flag,
also remove the anonymous accounts.
--rpm For internal use. This option is used by RPM files
during the MySQL installation process.
--skip-name-resolve Use IP addresses rather than hostnames when creating
grant table entries. This option can be useful if
your DNS does not work.
--srcdir=path The path to the MySQL source directory. This option
uses the compiled binaries and support files within the
source tree, useful for if you don't want to install
MySQL yet and just want to create the system tables.
--user=user_name The login username to use for running mysqld. Files
and directories created by mysqld will be owned by this
user. You must be root to use this option. By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
Any other options are passed to the mysqld program.
初始化mysql,成功的标志是有两个OK
[root@oracle scripts]# ./mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --defaults-file=/etc/my.cnf --user=mysql
Installing MySQL system tables...2017-03-28 17:17:47 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
OK
Filling help tables...2017-03-28 17:18:28 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
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 oracle 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
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
[root@oracle scripts]# cd /usr/local/mysql/bin
mysqld_safe建议用这个命令开启mysql 他是mysql的守护进程
[root@oracle bin]# ./mysqld_safe --help
Usage: ./mysqld_safe [OPTIONS]
--no-defaults Don't read the system defaults file
--defaults-file=FILE Use the specified defaults file
--defaults-extra-file=FILE Also use defaults from the specified file
--ledir=DIRECTORY Look for mysqld in the specified directory
--open-files-limit=LIMIT Limit the number of open files
--core-file-size=LIMIT Limit core files to the specified size
--timezone=TZ Set the system timezone
--malloc-lib=LIB Preload shared library LIB if available
--mysqld=FILE Use the specified file as mysqld
--mysqld-version=VERSION Use "mysqld-VERSION" as mysqld
--nice=NICE Set the scheduling priority of mysqld
--plugin-dir=DIR Plugins are under DIR or DIR/VERSION, if
VERSION is given
--skip-kill-mysqld Don't try to kill stray mysqld processes
--syslog Log messages to syslog with 'logger'
--skip-syslog Log messages to error log (default)
--syslog-tag=TAG Pass -t "mysqld-TAG" to 'logger'
All other options are passed to the mysqld program.
[root@oracle bin]# ./mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
Tips :mysqld_safe后面紧跟--defaults-file=/etc/my.cnf 这个参数
安装成功
[root@oracle bin]# ./mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.16-log MySQL Community Server (GPL)
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.02 sec)
mysql>
********mysql的用户密码信息,只需要保留‘localhost | root’
********root只能用于本地用户使用(DBA自己使用的)
mysql> select host,user,password from user;
+-----------+------+----------+
| host | user | password |
+-----------+------+----------+
| localhost | root | |
| oracle | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | | |
| oracle | | |
+-----------+------+----------+
6 rows in set (0.00 sec)
mysql> delete from user where host!='localhost' or user!='root';
Query OK, 5 rows affected (0.00 sec)
mysql> select host,user,password from user;
+-----------+------+----------+
| host | user | password |
+-----------+------+----------+
| localhost | root | |
+-----------+------+----------+
1 row in set (0.00 sec)
mysql> update user set password=password('root123');
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
+-----------+------+-------------------------------------------+
1 row in set (0.00 sec)
mysql> quit
Bye
[root@oracle bin]# ./mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.16-log MySQL Community Server (GPL)
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> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
[root@oracle bin]# ./mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@oracle 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.6.16-log MySQL Community Server (GPL)
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>
关闭mysql数据库
[root@oracle bin]# ./mysqladmin -uroot -proot123 shutdown
这是正常关闭数据库的命令,这样不会损坏数据文件
***如果忘记密码
[root@oracle bin]# ./mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-table &
[1] 4484
[root@oracle bin]# 170328 17:33:59 mysqld_safe Logging to '/data/mysql/error.log'.
170328 17:33:59 mysqld_safe Starting mysqld daemon with databases from /data/mysql
[root@oracle bin]#
[root@oracle bin]#
[root@oracle bin]# ./mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.16-log MySQL Community Server (GPL)
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>
创建单机多实例数据库
一般用多机多实例
[root@localhost mysql_3308]# cat /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld3306]
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql_3306
socket = /tmp/mysql_3306.sock
slow_query_log_file = /data/mysql_3306/slow.log
log-error = /data/mysql_3306/error.log
log-bin = /data/mysql_3306/mysql-bin
sync_binlog = 1
binlog_format=row
transaction_isolation = REPEATABLE-READ
innodb_buffer_pool_size = 100m
[mysqld3308]
port = 3308
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql_3308
socket = /tmp/mysql_3308.sock
slow_query_log = 1
slow_query_log_file = /data/mysql_3308/slow.log
log-error = /data/mysql_3308/error.log
long_query_time = 0.05
log-bin = /data/mysql_3308/mysql-bin
sync_binlog = 1
binlog_cache_size = 4M
default-storage-engine=InnoDB
binlog_format=row
transaction_isolation = REPEATABLE-READ
innodb_buffer_pool_size = 100m
[mysqld_multi]
mysqld=/usr/local/mysql/bin/mysqld_safe
mysqladmin=/usr/local/mysql/bin/mysqladmin
[root@localhost data]# ll
total 12
drwxr-xr-x 5 mysql mysql 4096 Apr 13 14:33 mysql
drwxr-xr-x 5 mysql mysql 4096 Apr 13 15:14 mysql_3306
drwxr-xr-x 5 mysql mysql 4096 Apr 13 15:14 mysql_3308
[root@localhost mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql_3306/ --defaults-file=/etc/my.cnf --user=mysql
Installing MySQL system tables...2017-04-13 15:44:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-04-13 15:44:06 6041 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-04-13 15:44:06 6041 [Note] InnoDB: The InnoDB memory heap is disabled
2017-04-13 15:44:06 6041 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-04-13 15:44:06 6041 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-04-13 15:44:06 6041 [Note] InnoDB: Using Linux native AIO
2017-04-13 15:44:06 6041 [Note] InnoDB: Using CPU crc32 instructions
2017-04-13 15:44:06 6041 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-04-13 15:44:06 6041 [Note] InnoDB: Completed initialization of buffer pool
2017-04-13 15:44:06 6041 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-04-13 15:44:06 6041 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-04-13 15:44:06 6041 [Note] InnoDB: Database physically writes the file full: wait...
2017-04-13 15:44:06 6041 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-04-13 15:44:06 6041 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-04-13 15:44:07 6041 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-04-13 15:44:07 6041 [Warning] InnoDB: New log files created, LSN=45781
2017-04-13 15:44:07 6041 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-04-13 15:44:07 6041 [Note] InnoDB: Doublewrite buffer created
2017-04-13 15:44:07 6041 [Note] InnoDB: 128 rollback segment(s) are active.
2017-04-13 15:44:07 6041 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-04-13 15:44:07 6041 [Note] InnoDB: Foreign key constraint system tables created
2017-04-13 15:44:07 6041 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-04-13 15:44:07 6041 [Note] InnoDB: Tablespace and datafile system tables created.
2017-04-13 15:44:07 6041 [Note] InnoDB: Waiting for purge to start
2017-04-13 15:44:07 6041 [Note] InnoDB: 5.6.16 started; log sequence number 0
2017-04-13 15:44:08 6041 [Note] Binlog end
2017-04-13 15:44:08 6041 [Note] InnoDB: FTS optimize thread exiting.
2017-04-13 15:44:08 6041 [Note] InnoDB: Starting shutdown...
2017-04-13 15:44:09 6041 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2017-04-13 15:44:09 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-04-13 15:44:09 6064 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-04-13 15:44:09 6064 [Note] InnoDB: The InnoDB memory heap is disabled
2017-04-13 15:44:09 6064 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-04-13 15:44:09 6064 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-04-13 15:44:09 6064 [Note] InnoDB: Using Linux native AIO
2017-04-13 15:44:09 6064 [Note] InnoDB: Using CPU crc32 instructions
2017-04-13 15:44:09 6064 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-04-13 15:44:09 6064 [Note] InnoDB: Completed initialization of buffer pool
2017-04-13 15:44:09 6064 [Note] InnoDB: Highest supported file format is Barracuda.
2017-04-13 15:44:09 6064 [Note] InnoDB: 128 rollback segment(s) are active.
2017-04-13 15:44:09 6064 [Note] InnoDB: Waiting for purge to start
2017-04-13 15:44:09 6064 [Note] InnoDB: 5.6.16 started; log sequence number 1625977
2017-04-13 15:44:09 6064 [Note] Binlog end
2017-04-13 15:44:09 6064 [Note] InnoDB: FTS optimize thread exiting.
2017-04-13 15:44:09 6064 [Note] InnoDB: Starting shutdown...
2017-04-13 15:44:11 6064 [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
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file /usr/local/mysql//my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql//my-new.cnf,
please compare it with your file and take the changes you need.
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@localhost mysql]# ./scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/mysql_3308/ --defaults-file=/etc/my.cnf --user=mysql
Installing MySQL system tables...2017-04-13 15:55:44 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-04-13 15:55:44 34767 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-04-13 15:55:44 34767 [Note] InnoDB: The InnoDB memory heap is disabled
2017-04-13 15:55:44 34767 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-04-13 15:55:44 34767 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-04-13 15:55:44 34767 [Note] InnoDB: Using Linux native AIO
2017-04-13 15:55:44 34767 [Note] InnoDB: Using CPU crc32 instructions
2017-04-13 15:55:44 34767 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-04-13 15:55:44 34767 [Note] InnoDB: Completed initialization of buffer pool
2017-04-13 15:55:44 34767 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-04-13 15:55:44 34767 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-04-13 15:55:44 34767 [Note] InnoDB: Database physically writes the file full: wait...
2017-04-13 15:55:45 34767 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-04-13 15:55:46 34767 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-04-13 15:55:47 34767 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-04-13 15:55:47 34767 [Warning] InnoDB: New log files created, LSN=45781
2017-04-13 15:55:47 34767 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-04-13 15:55:47 34767 [Note] InnoDB: Doublewrite buffer created
2017-04-13 15:55:47 34767 [Note] InnoDB: 128 rollback segment(s) are active.
2017-04-13 15:55:47 34767 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-04-13 15:55:47 34767 [Note] InnoDB: Foreign key constraint system tables created
2017-04-13 15:55:47 34767 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-04-13 15:55:47 34767 [Note] InnoDB: Tablespace and datafile system tables created.
2017-04-13 15:55:47 34767 [Note] InnoDB: Waiting for purge to start
2017-04-13 15:55:47 34767 [Note] InnoDB: 5.6.16 started; log sequence number 0
2017-04-13 15:55:48 34767 [Note] Binlog end
2017-04-13 15:55:48 34767 [Note] InnoDB: FTS optimize thread exiting.
2017-04-13 15:55:48 34767 [Note] InnoDB: Starting shutdown...
2017-04-13 15:55:49 34767 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2017-04-13 15:55:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-04-13 15:55:49 34790 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-04-13 15:55:49 34790 [Note] InnoDB: The InnoDB memory heap is disabled
2017-04-13 15:55:49 34790 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-04-13 15:55:49 34790 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-04-13 15:55:49 34790 [Note] InnoDB: Using Linux native AIO
2017-04-13 15:55:49 34790 [Note] InnoDB: Using CPU crc32 instructions
2017-04-13 15:55:49 34790 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-04-13 15:55:49 34790 [Note] InnoDB: Completed initialization of buffer pool
2017-04-13 15:55:49 34790 [Note] InnoDB: Highest supported file format is Barracuda.
2017-04-13 15:55:49 34790 [Note] InnoDB: 128 rollback segment(s) are active.
2017-04-13 15:55:49 34790 [Note] InnoDB: Waiting for purge to start
2017-04-13 15:55:49 34790 [Note] InnoDB: 5.6.16 started; log sequence number 1625977
2017-04-13 15:55:49 34790 [Note] Binlog end
2017-04-13 15:55:49 34790 [Note] InnoDB: FTS optimize thread exiting.
2017-04-13 15:55:49 34790 [Note] InnoDB: Starting shutdown...
2017-04-13 15:55:51 34790 [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
Support MySQL by buying support/licenses at http://shop.mysql.com
WARNING: Found existing config file /usr/local/mysql//my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql//my-new.cnf,
please compare it with your file and take the changes you need.
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@localhost bin]# ./mysqld_multi --help
mysqld_multi version 2.16 by Jani Tolonen
Description:
mysqld_multi can be used to start, reload, or stop any number of separate
mysqld processes running in different TCP/IP ports and UNIX sockets.
mysqld_multi can read group [mysqld_multi] from my.cnf file. You may
want to put options mysqld=... and mysqladmin=... there. Since
version 2.10 these options can also be given under groups [mysqld#],
which gives more control over different versions. One can have the
default mysqld and mysqladmin under group [mysqld_multi], but this is
not mandatory. Please note that if mysqld or mysqladmin is missing
from both [mysqld_multi] and [mysqld#], a group that is tried to be
used, mysqld_multi will abort with an error.
mysqld_multi will search for groups named [mysqld#] from my.cnf (or
the given --defaults-extra-file=...), where '#' can be any positive
integer starting from 1. These groups should be the same as the regular
[mysqld] group, but with those port, socket and any other options
that are to be used with each separate mysqld process. The number
in the group name has another function; it can be used for starting,
reloading, stopping, or reporting any specific mysqld server.
Usage: mysqld_multi [OPTIONS] {start|reload|stop|report} [GNR,GNR,GNR...]
or mysqld_multi [OPTIONS] {start|reload|stop|report} [GNR-GNR,GNR,GNR-GNR,...]
The GNR means the group number. You can start, reload, stop or report any GNR,
or several of them at the same time. (See --example) The GNRs list can
be comma separated or a dash combined. The latter means that all the
GNRs between GNR1-GNR2 will be affected. Without GNR argument all the
groups found will either be started, reloaded, stopped, or reported. Note that
syntax for specifying GNRs must appear without spaces.
Options:
These options must be given before any others:
--no-defaults Do not read any defaults file
--defaults-file=... Read only this configuration file, do not read the
standard system-wide and user-specific files
--defaults-extra-file=... Read this configuration file in addition to the
standard system-wide and user-specific files
Using:
--example Give an example of a config file with extra information.
--help Print this help and exit.
--log=... Log file. Full path to and the name for the log file. NOTE:
If the file exists, everything will be appended.
Using:
--mysqladmin=... mysqladmin binary to be used for a server shutdown.
Since version 2.10 this can be given within groups [mysqld#]
Using:
--mysqld=... mysqld binary to be used. Note that you can give mysqld_safe
to this option also. The options are passed to mysqld. Just
make sure you have mysqld in your PATH or fix mysqld_safe.
Using:
Please note: Since mysqld_multi version 2.3 you can also
give this option inside groups [mysqld#] in ~/.my.cnf,
where '#' stands for an integer (number) of the group in
question. This will be recognised as a special option and
will not be passed to the mysqld. This will allow one to
start different mysqld versions with mysqld_multi.
--no-log Print to stdout instead of the log file. By default the log
file is turned on.
--password=... Password for mysqladmin user.
--silent Disable warnings.
--tcp-ip Connect to the MySQL server(s) via the TCP/IP port instead
of the UNIX socket. This affects stopping and reporting.
If a socket file is missing, the server may still be
running, but can be accessed only via the TCP/IP port.
By default connecting is done via the UNIX socket.
--user=... mysqladmin user. Using: root
--verbose Be more verbose.
--version Print the version number and exit.
[root@localhost bin]# ./mysqld_multi start 3306
[root@localhost bin]# ./mysqld_multi start 3308
[root@localhost bin]# ./mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld3306 is running
MySQL server from group: mysqld3308 is running
检查数据库是否开启
[root@localhost bin]# ps -ef|grep mysql
root 34854 1 0 16:03 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --port=3306 --socket=/tmp/mysql.sock --basedir=/usr/local/mysql --datadir=/data/mysql_3306 --socket=/tmp/mysql_3306.sock --slow_query_log_file=/data/mysql_3306/slow.log --log-error=/data/mysql_3306/error.log --log-bin=/data/mysql_3306/mysql-bin --sync_binlog=1 --binlog_format=row --transaction_isolation=REPEATABLE-READ --innodb_buffer_pool_size=100m
mysql 35102 34854 1 16:03 pts/0 00:00:01 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql_3306 --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --slow-query-log-file=/data/mysql_3306/slow.log --log-bin=/data/mysql_3306/mysql-bin --sync-binlog=1 --binlog-format=row --transaction-isolation=REPEATABLE-READ --innodb-buffer-pool-size=100m --log-error=/data/mysql_3306/error.log --pid-file=/data/mysql_3306/localhost.localdomain.pid --socket=/tmp/mysql_3306.sock --port=3306
root 35133 1 0 16:03 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --port=3308 --socket=/tmp/mysql.sock --basedir=/usr/local/mysql --datadir=/data/mysql_3308 --socket=/tmp/mysql_3308.sock --slow_query_log=1 --slow_query_log_file=/data/mysql_3308/slow.log --log-error=/data/mysql_3308/error.log --long_query_time=0.05 --log-bin=/data/mysql_3308/mysql-bin --sync_binlog=1 --binlog_cache_size=4M --default-storage-engine=InnoDB --binlog_format=row --transaction_isolation=REPEATABLE-READ --innodb_buffer_pool_size=100m
mysql 35441 35133 1 16:03 pts/0 00:00:02 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql_3308 --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --slow-query-log=1 --slow-query-log-file=/data/mysql_3308/slow.log --long-query-time=0.05 --log-bin=/data/mysql_3308/mysql-bin --sync-binlog=1 --binlog-cache-size=4M --default-storage-engine=InnoDB --binlog-format=row --transaction-isolation=REPEATABLE-READ --innodb-buffer-pool-size=100m --log-error=/data/mysql_3308/error.log --pid-file=/data/mysql_3308/localhost.localdomain.pid --socket=/tmp/mysql_3308.sock --port=3308
root 35486 1591 0 16:05 pts/0 00:00:00 grep mysql
[root@localhost bin]# ./mysql -S /tmp/mysql_3306.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.16-log MySQL Community Server (GPL)
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.02 sec)
mysql>
[root@localhost bin]# ./mysql -S /tmp/mysql_3308.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.16-log MySQL Community Server (GPL)
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>
标签:13,15,04,部署,--,实例,mysql,2017 From: https://www.cnblogs.com/sddll/p/16867824.html