mysql数据库服务器通常指的的是mysqld,而命令行mysql则是mysql客户端程序,这两个概念通常容易混淆。通常启动mysql服务器即是启
mysql数据库服务器通常指的的是mysqld,而命令行mysql则是mysql客户端程序,这两个概念通常容易混淆。通常启动mysql服务器即是启动mysqld进程,mysqld启动后,可以通过mysql连接到mysql服务器。本文主要描述了mysql服务器的几种启动方式以及如何关闭mysql服务器。
--------------------------------------分割线 --------------------------------------
ubuntu 14.04下安装mysql
《mysql权威指南(原书第2版)》清晰中文扫描版 pdf
ubuntu 14.04 lts 安装 lnmp nginx\php5 (php-fpm)\mysql
ubuntu 14.04下搭建mysql主从服务器
ubuntu 12.04 lts 构建高可用分布式 mysql 集群
ubuntu 12.04下源代码安装mysql5.6以及python-mysqldb
mysql-5.5.38通用二进制安装
--------------------------------------分割线 --------------------------------------
1、直接使用mysqld启动
mysqld 即是mysql服务器,可以调用该命令直接启动mysql服务器
mysqld 从配置文件中读取[mysqld]以及[server]选项组的内容,,也可以通过直接在命令行跟随参数。
mysqld服务器读取配置文件的顺序,对于有多个配置文件存在,且同一参数有多个值的情形,以最后一次读取为准。
命令行跟随参数具有最高优先级
#当前mysql服务器运行环境
[root@rhel64a ~]# cat /etc/issue
red hat enterprise linux server release 6.4 (santiago)
#查看mysqld启动时的缺省选项
[root@rhel64a ~]# mysqld --print-defaults
mysqld would have been started with the following arguments:
--socket=/tmp/mysql3306.sock --port=3306 --pid-file=/var/lib/mysql/my3306.pid --user=mysql --server-id=3306 --federated
[root@rhel64a ~]# ps -ef|grep mysql
root 2963 2840 0 14:10 pts/0 00:00:00 grep mysql
# author : leshami
# blog :
#查看mysqld启动配置文件的优先级
[root@rhel64a ~]# mysqld --verbose --help |grep -a 1 default options
default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
#查看当前的my.cnf配置文件
[root@rhel64a ~]# grep -v ^# /etc/my.cnf|head -n 7
[mysqld]
socket = /tmp/mysql3306.sock
port = 3306
pid-file = /var/lib/mysql/my3306.pid
user = mysql
server-id=3306
federated
#清空当前mysql服务器的错误日志文件
[root@rhel64a ~]# cat /dev/null>/var/lib/mysql/rhel64a.ycdata.net.err
[root@rhel64a ~]# mysqld & #启动mysqld服务器
[1] 3480
[root@rhel64a ~]# 2014-10-25 14:20:42 0 [warning] timestamp with implicit default value is deprecated.
please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-10-25 14:20:42 3480 [note] innodb: using atomics to ref count buffer pool pages
2014-10-25 14:20:42 3480 [note] innodb: the innodb memory heap is disabled
2014-10-25 14:20:42 3480 [note] innodb: mutexes and rw_locks use gcc atomic builtins
2014-10-25 14:20:42 3480 [note] innodb: memory barrier is not used
2014-10-25 14:20:42 3480 [note] innodb: compressed tables use zlib 1.2.3
2014-10-25 14:20:42 3480 [note] innodb: using linux native aio
2014-10-25 14:20:42 3480 [note] innodb: using cpu crc32 instructions
2014-10-25 14:20:42 3480 [note] innodb: initializing buffer pool, size = 128.0m
2014-10-25 14:20:42 3480 [note] innodb: completed initialization of buffer pool
2014-10-25 14:20:42 3480 [note] innodb: highest supported file format is barracuda.
2014-10-25 14:20:42 3480 [note] innodb: 128 rollback segment(s) are active.
2014-10-25 14:20:42 3480 [note] innodb: waiting for purge to start
2014-10-25 14:20:42 3480 [note] innodb: 5.6.21 started; log sequence number 1626087
2014-10-25 14:20:42 3480 [note] server hostname (bind-address): '*'; port: 3306
2014-10-25 14:20:42 3480 [note] ipv6 is available.
2014-10-25 14:20:42 3480 [note] - '::' resolves to '::';
2014-10-25 14:20:42 3480 [note] server socket created on ip: '::'.
2014-10-25 14:20:42 3480 [note] event scheduler: loaded 0 events
2014-10-25 14:20:42 3480 [note] mysqld: ready for connections.
version: '5.6.21' socket: '/tmp/mysql3306.sock' port: 3306 mysql community server (gpl)l
#下面可以查询到mysqld进程
[root@rhel64a ~]# ps -ef|grep mysql|grep -v grep
mysql 18240 2641 1 20:25 pts/2 00:00:00 mysqld
[root@rhel64a ~]# mysql -uroot -pxxx -p3306 --protocol=tcp
root@localhost[(none)]> show variables like 'version';
+---------------+--------+
| variable_name | value |
+---------------+--------+
| version | 5.6.21 |
+---------------+--------+
更多详情见请继续阅读下一页的精彩内容: