1.建立数据目录

/data/mysql/3307/

shown -R mysql:mysql 3307

2.配置文件

#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]
user=mysql
port=3307
datadir=/data/mysql/3307
socket=/data/mysql/3307/mysql.sock
log_error=/data/logs/mariadb/3307_mariadb.log
server-id=2

#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
character-set-server=utf8

# This group is only read by MariaDB-10.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.5]

#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#


[client]
socket=/data/mysql/3306/mysql.sock

# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
default-character-set=utf8

3.初始化数据库

/usr/bin/mysql_install_db --defaults-file=/data/mysql/3307/my.cnf --datadir=/data/mysql/3307

4. 启动

/usr/bin/mysqld_safe --defaults-file=/data/mysql/3307/my.cnf --skip-grant-tables 2>&1 > /dev/null &

5. 修改密码 

 mysql -uroot -p -S /data/mysql/3307/mysql.sock  空密码登陆

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'jetsong2326';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY 'jetsong2326';
flush privileges;

6. /usr/bin/mysqld_safe --defaults-file=/data/mysql/3307/my.cnf  2>&1 > /dev/null &

7.管理脚本

#!/bin/bash

. /etc/init.d/functions

PORT=$2

USER=root

PASSWD=123456

MYSQLBIN='/usr/local/mysql/bin'

SOCKETFILE="/multidata/${PORT}/mysql.sock"

PIDFILE="/multidata/${PORT}/mysql.pid"

MYCNF="/multidata/${PORT}/my.cnf"

[[ $# -eq 2 ]] || {

   echo "Usage: $0 {start|stop|restart|reload} {PORT}"

   exit 1

}

mysql_start() {

   [[ -e "$SOCKETFILE" ]] && {

       action "MySQL port: $PORT IS already running" /bin/false

       exit 0

   } || {

       action "Starting MySQL...  please wait" /bin/true

       $MYSQLBIN/mysqld_safe --defaults-file=$MYCNF &> /dev/null &

   }

   [[ "$?" == "0" ]] && {

       action "MySQL has been Started" /bin/true

   } || {

       action "MySQL Started" /bin/false

   }

}

mysql_stop() {

   [[ ! -e "$SOCKETFILE" ]] && {

       action "MySQL port:$PORT was already down" /bin/false

   } || {

       $MYSQLBIN/mysqladmin -u $USER -p$PASSWD -S $SOCKETFILE shutdown &>/dev/null

   }

   [[ "$?" == 0 ]] && {

       action  "MySQL port:$PORT has been Stopped" /bin/true

   }

}

case "$1" in

'start')

   mysql_start

   ;;

'stop')

   mysql_stop

   ;;

'restart'|'reload')

   mysql_stop

   sleep 3

   mysql_start

   ;;

*)

   echo "Usage: $0 {start|stop|restart|reload} {PORT}"

esac

 

标签: none

已有 20 条评论

  1. 怎么收藏这篇文章?

  2. 不错不错,我喜欢看 https://www.237fa.com/

  3. 兄弟写的非常好 https://www.cscnn.com/

  4. 《对决2016》动作片高清在线免费观看:https://www.jgz518.com/xingkong/94407.html

  5. 《圣诞保卫战》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/151589.html

  6. 《对决2016》动作片高清在线免费观看:https://www.jgz518.com/xingkong/94407.html

  7. 《圣诞保卫战》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/151589.html

  8. 《我的非常闺蜜(完整版)》国产剧高清在线免费观看:https://www.jgz518.com/xingkong/166591.html

  9. 《变身国王2:高刚外传》动画片高清在线免费观看:https://www.jgz518.com/xingkong/12283.html

  10. 《我的非常闺蜜(完整版)》国产剧高清在线免费观看:https://www.jgz518.com/xingkong/166591.html

  11. 《变身国王2:高刚外传》动画片高清在线免费观看:https://www.jgz518.com/xingkong/12283.html

  12. 《难以置信2018》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/121763.html

  13. 《德云社郭德纲于谦相声专场上海站 2023》大陆综艺高清在线免费观看:https://www.jgz518.com/xingkong/28686.html

  14. 选材新颖独特,通过细节描写赋予主题鲜活生命力。

  15. ?学术类评语?

  16. 作者对主题的挖掘深入骨髓,展现了非凡的洞察力和理解力。

  17. 文字流畅如丝,语言优美动人,读来令人心旷神怡。

  18. 作者以简洁明了的语言,传达了深刻的思想和情感。

  19. 新盘首开 新盘首开 征召客户!!!coinsrore.com

  20. 2025年10月新盘 做第一批吃螃蟹的人coinsrore.com
    新车新盘 嘎嘎稳 嘎嘎靠谱coinsrore.com
    新车首发,新的一年,只带想赚米的人coinsrore.com
    新盘 上车集合 留下 我要发发 立马进裙coinsrore.com
    做了几十年的项目 我总结了最好的一个盘(纯干货)coinsrore.com
    新车上路,只带前10个人coinsrore.com
    新盘首开 新盘首开 征召客户!!!coinsrore.com
    新项目准备上线,寻找志同道合 的合作伙伴coinsrore.com
    新车即将上线 真正的项目,期待你的参与coinsrore.com
    新盘新项目,不再等待,现在就是最佳上车机会!coinsrore.com
    新盘新盘 这个月刚上新盘 新车第一个吃螃蟹!coinsrore.com

添加新评论