MySQL常见的启动和操作(MySQL.57.x)

1、手动启动:

 1 [root@node ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
 2 [1] 15689
 3 [root@node ~]# nets2018-05-06T08:10:50.238854Z mysqld_safe Logging to '/data/mysql/error.log'.
 4 t2018-05-06T08:10:50.293504Z mysqld_safe Starting mysqld daemon with databases from /data/mysql
 5 
 6 -bash: netst: command not found
 7 [root@node ~]# netstat -unltp|grep 3306
 8 tcp6       0      0 :::3306                 :::*                    LISTEN      16984/mysqld        
 9 [root@node ~]# ps xua|grep mysqld
10 root      15689  0.2  0.0 113252  1660 pts/0    S    16:10   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
11 mysql     16984  1.1 14.7 2331244 275008 pts/0  Sl   16:10   0:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/error.log --open-files-limit=65535 --pid-file=node.pid --socket=/tmp/mysql.sock --port=3306
12 root      17027  0.0  0.0 112644   952 pts/0    S+   16:11   0:00 grep --color=auto mysqld
13 [root@node ~]# 

2、手动关闭:

1 [root@node ~]# /usr/local/mysql/bin/mysqladmin -uroot -hlocalhost -proot@123 shutdown
2 mysqladmin: [Warning] Using a password on the command line interface can be insecure.
3 [root@node ~]# 2018-05-06T08:12:58.958427Z mysqld_safe mysqld from pid file /data/mysql/node.pid ended
4 
5 [1]+  Done                    /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
6 [root@node ~]# 
7 [root@node ~]# ps xua|grep mysqld
8 root      17036  0.0  0.0 112644   952 pts/0    S+   16:13   0:00 grep --color=auto mysqld
9 [root@node ~]# 

3、shell下查看MySQL数据库下表结构:

 1 [root@node ~]# mysql -uroot -hlocalhost -p -e "use mysql;select User,Host,authentication_string from user;"
 2 Enter password: 
 3 +---------------+-----------+-------------------------------------------+
 4 | User          | Host      | authentication_string                     |
 5 +---------------+-----------+-------------------------------------------+
 6 | root          | localhost | *A00C34073A26B40AB4307650BFB9309D6BFA6999 |
 7 | mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
 8 | mysql.sys     | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
 9 +---------------+-----------+-------------------------------------------+
10 [root@node ~]# 

注意"-e"参数的使用

猜你喜欢

转载自www.cnblogs.com/kindnull/p/8998567.html
今日推荐