启停onesql,总共四个参数{start|stop|restart|status},只要稍微改一下头部的三个文件路径,即可完成mysql单实例的启停。
[#9(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 Usage:sh /etc/init.d/onesql5.6.26 {start|stop|restart|status}
详细执行效果如下:
[#2(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 status There is no mysqld process ! [#3(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 stop The mysqld process is already stopped ! [#4(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 start Starting MySQL. 150830 13:15:06 mysqld_safe Logging to '/data/mysql/mysql_3307/logs/error3307.log'. 150830 13:15:06 mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql_3307/data Starting MySQL.. SUCCESS! [#5(zhouxx_vm(node3:192.168.56.103))#root@node3~]# [#5(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 status root 2319 1 2 13:15 pts/0 00:00:00 /bin/sh /usr/local/onesql5.6/bin/mysqld_safe --defaults-file=/data/mysql/mysql_3307/my_3307.cnf --user=mysql --datadir=/data/mysql/mysql_3307/data --basedir=/usr/local/onesql5.6 mysql 3163 2319 44 13:15 pts/0 00:00:02 /usr/local/onesql5.6/bin/mysqld --defaults-file=/data/mysql/mysql_3307/my_3307.cnf --basedir=/usr/local/onesql5.6 --datadir=/data/mysql/mysql_3307/data --plugin-dir=/usr/local/onesql5.6/lib/plugin --user=mysql --log-error=/data/mysql/mysql_3307/logs/error3307.log --open-files-limit=58000 --pid-file=/data/mysql/mysql_3307/logs/mysql_3307.pid --socket=/tmp/mysql_3307.sock --port=3307 MySQL(pid=3163) Status -------------- /usr/local/onesql5.6/bin/mysql Ver 14.14 Distrib 5.6.25, for Linux (x86_64) using EditLine wrapper Connection id: 4 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.6.26-log (OneSQL) Source distribution Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /tmp/mysql_3307.sock Uptime: 5 sec Threads: 4 Questions: 5 Slow queries: 0 Opens: 18 Flush tables: 1 Open tables: 11 Queries per second avg: 1.000 -------------- [#6(zhouxx_vm(node3:192.168.56.103))#root@node3~]# [#6(zhouxx_vm(node3:192.168.56.103))#root@node3~]# [#6(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 stop 150830 13:15:19 mysqld_safe mysqld from pid file /data/mysql/mysql_3307/logs/mysql_3307.pid ended Stopping MySQL SUCCESS! [#7(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 restart The mysqld process is already stopped ! 150830 13:15:32 mysqld_safe Logging to '/data/mysql/mysql_3307/logs/error3307.log'. 150830 13:15:32 mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql_3307/data Starting MySQL. SUCCESS! [#8(zhouxx_vm(node3:192.168.56.103))#root@node3~]#service onesql5.6.26 status root 3266 1 3 13:15 pts/0 00:00:00 /bin/sh /usr/local/onesql5.6/bin/mysqld_safe --defaults-file=/data/mysql/mysql_3307/my_3307.cnf --user=mysql --datadir=/data/mysql/mysql_3307/data --basedir=/usr/local/onesql5.6 mysql 4107 3266 63 13:15 pts/0 00:00:02 /usr/local/onesql5.6/bin/mysqld --defaults-file=/data/mysql/mysql_3307/my_3307.cnf --basedir=/usr/local/onesql5.6 --datadir=/data/mysql/mysql_3307/data --plugin-dir=/usr/local/onesql5.6/lib/plugin --user=mysql --log-error=/data/mysql/mysql_3307/logs/error3307.log --open-files-limit=58000 --pid-file=/data/mysql/mysql_3307/logs/mysql_3307.pid --socket=/tmp/mysql_3307.sock --port=3307 MySQL(pid=4107) Status -------------- /usr/local/onesql5.6/bin/mysql Ver 14.14 Distrib 5.6.25, for Linux (x86_64) using EditLine wrapper Connection id: 4 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.6.26-log (OneSQL) Source distribution Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /tmp/mysql_3307.sock Uptime: 4 sec Threads: 4 Questions: 5 Slow queries: 0 Opens: 18 Flush tables: 1 Open tables: 11 Queries per second avg: 1.250 -------------- [#9(zhouxx_vm(node3:192.168.56.103))#root@node3~]#
详细脚本
[#10(zhouxx_vm(node3:192.168.56.103))#root@node3~]#cat /etc/init.d/onesql5.6.26 #!/bin/sh ##source /etc/profile #MYSQL_HOME=/usr/local/mysql5.6.26 MYSQL_HOME=/usr/local/onesql5.6 datadir=/data/mysql/mysql_3307/data mysql_cnf="/data/mysql/mysql_3307/my_3307.cnf" mysql_sock="/tmp/mysql_3307.sock" function start(){ mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'` if [ "0" = "$mysqld_pid"0 ] then $MYSQL_HOME/bin/mysqld_safe --defaults-file="$mysql_cnf" --user=mysql --datadir="$datadir" --basedir="$MYSQL_HOME" & sleep 1 mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'` mysqld_pid1="$mysqld_pid"0 pppct="." while [[ $mysqld_pid1 -lt 1 ]] do mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'` mysqld_pid1="$mysqld_pid"0 if [ $mysqld_pid1 -gt 1 ] then #clear echo "Starting MySQL$pppct SUCCESS! " else #clear echo "Starting MySQL$pppct" fi pppct="$pppct." sleep 1 done else echo "A mysqld process already exists ! pid:$mysqld_pid" fi } function stop(){ mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'` if [ "0" = "$mysqld_pid"0 ] then echo "The mysqld process is already stopped ! " else #/usr/local/mysql/bin/mysqladmin –S "$mysql_sock" shutdown & $MYSQL_HOME/bin/mysqladmin -S "$mysql_sock" shutdown & sleep 2 mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'` if [ "0" = "$mysqld_pid"0 ] then echo "Stopping MySQL$pppct SUCCESS! " else mysqld_pid1="$mysqld_pid"0 pppct="." while [ "$mysqld_pid1" != "0" ] do mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'` mysqld_pid1="$mysqld_pid"0 if [ "$mysqld_pid1" = "0" ] then #clear echo "Stopping MySQL$pppct SUCCESS! " else #clear echo "Stopping MySQL$pppct" fi pppct="$pppct." sleep 1 done fi fi } function status(){ mysqld_pid=`ps -ef|grep mysqld|grep "$mysql_sock" |grep -vE 'grep|mysqld_safe'|awk '{print $2}'` if [ "0" = "$mysqld_pid"0 ] then echo "There is no mysqld process ! " else echo -e "\n" ps -ef|grep mysqld|grep "$mysql_cnf"|grep -v grep echo -e "MySQL(pid=$mysqld_pid) Status \n " #mysqladmin -S "$mysql_sock" status $MYSQL_HOME/bin/mysql -S "$mysql_sock" -e "\s;" echo -e "\n" fi } case "$1" in start) start ;; stop) stop ;; status) status ;; restart) stop start ;; *) echo "Usage:sh $0 {start|stop|restart|status}" esac exit [#11(zhouxx_vm(node3:192.168.56.103))#root@node3~]#

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
