mysql怎么用sb文件_mysql脚本mysql_safe解释、mysql.sock文件、mysql_install_db
1、首先解釋下,啟動mysql時為何會調(diào)用mysql_safe腳本來啟動mysql
[root@localhost ~]# /etc/init.d/mysqld start
正在啟動 mysqld: [確定]
[root@localhost~]# ps -ef |grep mysql
root13052 1 0 11:41 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql13283 13052 20 11:41 pts/0 00:00:03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root14814 2418 0 11:41 pts/0 00:00:00grep mysql
[root@localhost~]#
mysql_safe:mysql服務(wù)啟動腳本
1 [root@localhost ~]# cat /etc/init.d/mysqld2 #!/bin/sh3 #4 # mysqld This shell script takes care of starting and stopping5 # the MySQL subsystem (mysqld).6 exec="/usr/bin/mysqld_safe"
7 prog="mysqld"
8 $exec --datadir="$datadir" --socket="$socketfile"\9 --pid-file="$mypidfile"\10 --basedir=/usr --user=mysql >/dev/null 2>&1 &
11 safe_pid=$!
解釋:因為/etc/init.d/mysqld是一個shell啟動腳本,啟動后最終會調(diào)用mysqld_safe腳本,最后請用mysqld腳本啟動mysql,如下:/etc/init.d/mysqld腳本中調(diào)用mysqld_safe的程序。
2、mysql.sock文件
mysql.sock文件是用來服務(wù)器與本地客戶端進(jìn)行通信的Unix套接字文件,它比tcp快。通常遇到這個問題的原因就是你的mysql server沒運行起來。
[root@localhost ~]# mysql -p
Enter password:
ERROR2002 (HY000): Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock'(2)
[root@localhost ~]# service mysqld start
正在啟動 mysqld: [確定]
[root@localhost~]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection idis 2Server version:5.6.29MySQL Community Server (GPL)
Copyright (c)2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracleis 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.sock文件所處位置:一般為:
[root@localhost ~]# cat /etc/my.cnf
[mysqld]
socket=/var/lib/mysql/mysql.sock
Mysql有兩種連接方式:
(1)TCP/IP
(2)socket
對mysql.sock來說,其作用是程序與mysqlserver處于同一臺機器,發(fā)起本地連接時可用。 不需要自定義host。因此,即使你改變mysql的外部port也是一樣可能正常連接。 因為你在my.ini中或my.cnf中改變端口后,mysql.sock是隨每一次 mysql server啟動生成的。已經(jīng)根據(jù)你在更改完my.cnf后重啟mysql時重新生成了一次,信息已跟著變更。?那么對于外部連接,必須是要變更host才能連接的。
3、mysql_install_db:初始化MYSQL數(shù)據(jù)庫目錄.
[root@localhost ~]# mysql_install_db --datadir=/var/lib/mysql/Installing MySQL system tables...2016-03-15 11:00:50 0 [Warning] TIMESTAMP wi
總結(jié)
以上是生活随笔為你收集整理的mysql怎么用sb文件_mysql脚本mysql_safe解释、mysql.sock文件、mysql_install_db的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python antlr4需要的pyth
- 下一篇: mybatis配置id自增mysql_m