启停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~]#

mySqlStringTypesimpactStorageAndPerformanCeaseAsfollows:1)长度,始终使用theSamestoragespace,whatcanbefasterbutlessspace-felfficity.2)varCharisvariable varcharisvariable length,morespace-morespace-morespace-effficitybuteftife buteftife butfority butfority textifforlyslower.3)

mySqlStringTypesIncludeVarChar,文本,char,enum和set.1)varCharisVersAtileForvariable-lengthStringStringSuptOptoPeptoPepecifientlimit.2)textisidealforlargetStortStorStoverStorextorewiteWithoutAdefinedLengthl.3)charlisfixed-Length

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

toadduserInmysqleffectection andsecrely,theTheSepsps:1)USEtheCreateuserStattoDaneWuser,指定thehostandastrongpassword.2)GrantNectalRevileSaryPrivilegesSustate,usiveleanttatement,AdheringTotheTeprinciplelastPrevilegege.3)

toaddanewuserwithcomplexpermissionsinmysql,loldtheSesteps:1)创建eTheEserWithCreateuser'newuser'newuser'@''localhost'Indedify'pa ssword';。2)GrantreadAccesstoalltablesin'mydatabase'withGrantSelectOnMyDatabase.to'newuser'@'localhost';。3)GrantWriteAccessto'

MySQL中的字符串数据类型包括CHAR、VARCHAR、BINARY、VARBINARY、BLOB、TEXT,排序规则(Collations)决定了字符串的比较和排序方式。1.CHAR适合固定长度字符串,VARCHAR适合可变长度字符串。2.BINARY和VARBINARY用于二进制数据,BLOB和TEXT用于大对象数据。3.排序规则如utf8mb4_unicode_ci忽略大小写,适合用户名;utf8mb4_bin区分大小写,适合需要精确比较的字段。

最佳的MySQLVARCHAR列长度选择应基于数据分析、考虑未来增长、评估性能影响及字符集需求。1)分析数据以确定典型长度;2)预留未来扩展空间;3)注意大长度对性能的影响;4)考虑字符集对存储的影响。通过这些步骤,可以优化数据库的效率和扩展性。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

禅工作室 13.0.1
功能强大的PHP集成开发环境

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具