4)为mysql提供sysv服务脚本并启动服务
[root@linuxidc support-files]# pwd
/usr/local/mysql/support-files
[root@linuxidc support-files]# cp mysql.server /etc/init.d/mysqld # mysql源码包自带服务脚本
[root@linuxidc support-files]# chkconfig --add mysqld
[root@linuxidc support-files]# chkconfig mysqld on
[root@linuxidc support-files]# chkconfig mysqld --list
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@linuxidc support-files]# /etc/init.d/mysqld start
Starting MySQL....
[root@linuxidc support-files]# netstat -tulnp | grep mysql # 已经监听
tcp 0 0 :::3306 :::* LISTEN 19605/mysqld
5)输出mysql的man手册至man命令的查找路径
[root@linuxidc support-files]# vim /etc/man.config
MANPATH /usr/local/mysql/man
6)输出mysql的头文件至系统头文件路径/usr/include
[root@linuxidc mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
`/usr/include/mysql' -> `/usr/local/mysql/include/'
7)输出mysql的库文件给系统库查找路径
[root@linuxidc mysql]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib # 在系统的库文件自动加载目录下新建mysql.conf文件,直接将mysql的库路径路径写入
[root@linuxidc mysql]# ldconfig -v # 让系统重新读取库文件
8)修改PATH环境变量,让系统可以直接使用mysql的相关命令
[root@linuxidc mysql]# vim /etc/profile.d/mysql.sh # 添加环境变量(与添加httpd是一样的)
export PATH=$PATH:/usr/local/mysql/bin
[root@linuxidc mysql]# source /etc/profile.d/mysql.sh # 重新读取一下环境变量
9)重启mysql,测试并连接mysql
[root@linuxidc mysql]# /etc/init.d/mysqld restart
Shutting down MySQL.. [ OK ]
Starting MySQL. [ OK ]
[root@linuxidc mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.34 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)