码迷,mamicode.com
首页 > 数据库 > 详细

MySQL8.0初始化配置方式 ——维护使用

时间:2020-05-25 00:09:18      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:mysql8   cli   dql   mysqld   err   erro   class   通过命令   mysqldump   

初始化配置

MySQL的启动方式

可以通过命令行的方式,传入启动参数,如果配置文件内的参数和命令行传入的参数相同,以命令行参数为准

[root@db ~]# ps -ef|grep mydqld
root       1179   1058  0 10:17 pts/0    00:00:00 grep --color=auto mydqld
[root@db ~]# ps -ef|grep mys
root        772      1  0 07:54 ?        00:00:00 /bin/sh /usr/local/mysql8/bin/mysqld_safe --datadir=/data/mysql/data_3306 --pid-file=/data/mysql/data_3306/db.pid
mysql       955    772  0 07:54 ?        00:00:43 /usr/local/mysql8/bin/mysqld --basedir=/usr/local/mysql8 --datadir=/data/mysql/data_3306 --plugin-dir=/usr/local/mysql8/lib/plugin --user=mysql --log-error=db.err --pid-file=/data/mysql/data_3306/db.pid --socket=/tmp/myql.sock --port=3306

举例:忘记root密码

[root@localhost ~]# /etc/init.d/mysqld stop
[root@localhost ~]# mysqld_safe --port=3329 &

[root@localhost ~]# ss -lntp
State       Recv-Q Send-Q           Local Address:Port                          Peer Address:Port              
LISTEN      0      128                          *:22                                       *:*                   users:(("sshd",pid=781,fd=3))
LISTEN      0      128                         :::3329                                    :::*                   users:(("mysqld",pid=2595,fd=29))
LISTEN      0      70                          :::33060                                   :::*                   users:(("mysqld",pid=2595,fd=32))
LISTEN      0      128                         :::22                                      :::*                   users:(("sshd",pid=781,fd=4))

[root@localhost ~]# mysql -uroot -p123456
[root@localhost ~]# mysqld_safe --skip-grant-tables --skip-networking &
[root@localhost ~]# mysql

配置文件的加载顺序

[root@localhost ~]# mysqld --help --verbose|grep my.cnf
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf  

初始化配置文件应用

mysql配置文件格式

[标签]
配置=xxx
配置=xxx
配置=xxx
…

[标签]

标签分为两种

server端:
    [server]
    [mysqld]
    [mysqld_safe]
client端(只影响本地连接,不影响远程):
    [client]
    [mysql]
    [mysqldump]

调用非默认路径配置文件

mysqld_safe --defaults-file=配置文件路径 &

MySQL8.0初始化配置方式 ——维护使用

标签:mysql8   cli   dql   mysqld   err   erro   class   通过命令   mysqldump   

原文地址:https://www.cnblogs.com/zh-dream/p/12953168.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!