[iyunv@db01 ~]# cd /application/mysql/scripts/
3306实例
[iyunv@db01 scripts]# /application/mysql/scripts/mysql_install_db \
> --basedir=/application/mysql \
> --datadir=/data/3306/data \
> --user=mysql
WARNING: The host 'db01' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
161117 14:14:14 [Note] /application/mysql/bin/mysqld (mysqld 5.5.52) starting as process 46676 ...
OK
Filling help tables...
161117 14:14:15 [Note] /application/mysql/bin/mysqld (mysqld 5.5.52) starting as process 46683 ...
OK
如果有两个ok,就表示初始化成功
3307实例
[iyunv@db01 scripts]# /application/mysql/scripts/mysql_install_db \
> --basedir=/application/mysql \
> --datadir=/data/3307/data \
> --user=mysql
Installing MySQL system tables...
161117 14:18:20 [Note] /application/mysql/bin/mysqld (mysqld 5.5.52) starting as process 46733 ...
OK
Filling help tables...
161117 14:18:21 [Note] /application/mysql/bin/mysqld (mysqld 5.5.52) starting as process 46740 ...
OK
如果有两个ok,就表示初始化成功
7、启动多实例:
1)查看数据库状态
1
2
3
4
5
mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf report
[iyunv@db01 ~]# mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf report
Reporting MySQL servers
MySQL server from group: mysqld1 is not running
MySQL server from group: mysqld2 is not running
2)启动数据库
1
2
3
4
5
[iyunv@db01 ~]# mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf start 1,2
[iyunv@db01 ~]# mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf report
Reporting MySQL servers
MySQL server from group: mysqld1 is running
MySQL server from group: mysqld2 is running
[iyunv@db01 ~]# mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf stop 1,2
[iyunv@db01 ~]# mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf report
Reporting MySQL servers
MySQL server from group: mysqld1 is not running
MySQL server from group: mysqld2 is not running
[iyunv@db01 ~]# mysql -uroot -h127.0.0.1 -P3306
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.52 Source distribution
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>
方法二:指定socket登陆,适合在本机连接
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@db01 ~]# mysql -S /data/3307/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.52 Source distribution
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.