mysql运维与分析_mysql运维与分析--启动 停止 重启

1、查看mysql版本

方法一:status;

方法二:select version();

2、Mysql启动、停止、重启常用命令

a、启动方式

1、使用 service 启动:

[root@localhost /]# service mysqld start (5.0版本是mysqld)

[root@szxdb etc]# service mysql start (5.5.7版本是mysql)

2、使用 mysqld 脚本启动:

/etc/inint.d/mysqld start

3、使用 safe_mysqld 启动:

safe_mysqld&

b、停止

1、使用 service 启动:

service mysqld stop

2、使用 mysqld 脚本启动:

/etc/inint.d/mysqld stop

3、mysqladmin shutdown

c、重启

1、使用 service 启动:

service mysqld restart

service mysql restart (5.5.7版本命令)

2、使用 mysqld 脚本启动:

/etc/init.d/mysqld restart

service mysqld stop

Absolute path to 'service' is '/sbin/service', so it might be intended to be run only by user with superuser privileges (eg. root).

-bash: service: command not found

只有管理员才能使用service命令

mysqladmin shutdown

mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'

Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

没有sock文件

mysqladmin shutdown -S"/etc/mysock/ad2.sock"

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'ad2'@'localhost' (using password: NO)'

默认使用的linux终端用户没有权限本地访问数据库。

查一下mysql.user表,也没有这个终端用户。

mysqladmin shutdown -S"/etc/mysock/ad2.sock" -u my_dba

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'my_dba'@'localhost' (using password: NO)'

没有使用密码,无法操作

mysqladmin shutdown -S"/etc/mysock/ad2.sock" -u my_dba -p

Enter password:

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'my_dba'@'localhost' (using password: YES)'

虽然手动输入了密码,但是密码不正确。

输入正确密码,一切OK。

mysqld_safe --defaults-file=/etc/myconf/ad.cnf --socket=/etc/msock/ad.sock  --basedir=/usr/local/mysql  --ledir=/usr/local/mysql/bin  --mysqld=mysqld

161222 16:33:34 mysqld_safe The file /home/build/bin/mysqld

does not exist or is not executable. Please cd to the mysql installation

mysqld_safe --defaults-file=/etc/myconf/ad.cnf --socket=/etc/mysock/ad.sock  --basedir=/usr/local/mysql

依旧报相同的错误

mysqld_safe --defaults-file=/etc/myconf/ad.cnf --socket=/etc/mysock/ad.sock  --ledir=/usr/local/mysql/bin

161222 17:01:58 mysqld_safe Logging to '/test/cu_ipsad/data/cu_ipsad/duizhang_phy.err'.

161222 17:01:58 mysqld_safe Starting mysqld daemon with databases from /test/cu_ipsad/data/cu_ipsad

161222 17:02:03 mysqld_safe mysqld from pid file /test/cu_ipsad/data/cu_ipsad/duizhang_phy.pid ended

没有成功

mysqld_safe --defaults-file=/etc/myconf/ad.cnf --socket=/etc/msock/ad.sock  --basedir=/usr/local/mysql  --ledir=/usr/local/mysql/bin

成功

说明必须包含basedir和ledir选项

增加后台启动

mysqld_safe --defaults-file=/etc/myconf/ad.cnf --socket=/etc/mysock/ad.sock  --basedir=/usr/local/mysql  --ledir=/usr/local/mysql/bin &

成功

mysqladmin shutdown -S'/etc/mysock/ad.sock' -u my_dba -p

成功

mysqld_safe --defaults-file=/etc/myconf/ad.cnf --socket=/etc/mysock/ad.sock  --basedir=/usr/local/mysql  --ledir=/usr/local/mysql/bin >/dev/null 2>&1 &

成功

mysqladmin shutdown -S'/etc/mysock/ad.sock' -u my_dba -p

查看选项mysqld_safe

mysqld_safe --help

Usage: /usr/local/mysql/bin/mysqld_safe [OPTIONS]

--no-defaults              Don't read the system defaults file

--defaults-file=FILE       Use the specified defaults file

--defaults-extra-file=FILE Also use defaults from the specified file

--ledir=DIRECTORY          Look for mysqld in the specified directory

--open-files-limit=LIMIT   Limit the number of open files

--core-file-size=LIMIT     Limit core files to the specified size

--timezone=TZ              Set the system timezone

--malloc-lib=LIB           Preload shared library LIB if available

--mysqld=FILE              Use the specified file as mysqld

--mysqld-version=VERSION   Use "mysqld-VERSION" as mysqld

--nice=NICE                Set the scheduling priority of mysqld

--plugin-dir=DIR           Plugins are under DIR or DIR/VERSION, if

VERSION is given

--skip-kill-mysqld         Don't try to kill stray mysqld processes

--syslog                   Log messages to syslog with 'logger'

--skip-syslog              Log messages to error log (default)

--syslog-tag=TAG           Pass -t "mysqld-TAG" to 'logger'

All other options are passed to the mysqld program.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值