昨天初始化mysql数据库,今天开机进行相关调优、配置


首先查看到mysql开机没有

[root@dataserver ~]# ss -lntup|grep mysql

配置/etc/rc.local 将mysql设置为开机启动

方法一、

[root@dataserver ~]# vim /etc/rc.local 

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/etc/init.d/mysqld start
~                       
~
~
~                                                                                                                                                                                                                    
"/etc/rc.local" 8L, 245C 已写入                                                                                                                                                                                           
[root@dataserver ~]# reboot
[root@dataserver ~]# ss -lntup|grep mysql
tcp    LISTEN     0      50                     *:3306                  *:*      users:(("mysqld",1459,10))

方法二、

[root@dataserver ~]chkconfig --add mysqld

[root@dataserver ~]chkconfig mysqld on

[root@dataserver ~]reboot 

重启查看是否生效

[root@dataserver ~]# reboot


Broadcast message from root@dataserver

        (/dev/pts/1) at 5:26 ...


The system is going down for reboot NOW!

[root@dataserver ~]# 

Last login: Wed Sep 27 05:21:53 2017 from 192.168.3.3

[root@dataserver ~]# ss -lntup|grep mysql

tcp    LISTEN     0      50                     *:3306                  *:*      users:(("mysqld",1459,10))


[root@dataserver ~]# mysql -uroot -pdongliqiang

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.5.32 Source distribution


Copyright (c) 2000, 2013, 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 |

| dongliqiang        |

| mysql              |

| performance_schema |

| test               |

+--------------------+

5 rows in set (0.06 sec)


开机启动还有其他种方法,大家自行尝试,掌握最常用的集中就行了